[+] fix percentage
This commit is contained in:
parent
e06a1f4007
commit
93f023dda3
2
deps/com.github.aiortc.aiortc
vendored
2
deps/com.github.aiortc.aiortc
vendored
@ -1 +1 @@
|
||||
Subproject commit e1778f22d5f5ab5c1025191dd7faa35c653ce45b
|
||||
Subproject commit d3cdc32f8c474d90e48ecc4729c0088999cb82ad
|
@ -2286,6 +2286,26 @@ def desktop_services(argv):
|
||||
else:
|
||||
return 0
|
||||
|
||||
@property
|
||||
def percentage_low(self) -> int:
|
||||
try:
|
||||
return int(subprocess.check_output(r'''
|
||||
cat /etc/UPower/UPower.conf | grep -Po '^PercentageLow=\d+'
|
||||
''', shell=True,).decode('utf-8').strip().split('=')[1])
|
||||
except:
|
||||
logger.exception('')
|
||||
return 15
|
||||
|
||||
@property
|
||||
def percentage_critical(self) -> int:
|
||||
try:
|
||||
return int(subprocess.check_output(r'''
|
||||
cat /etc/UPower/UPower.conf | grep -Po '^PercentageCritical=\d+'
|
||||
''', shell=True,).decode('utf-8').strip().split('=')[1])
|
||||
except:
|
||||
logger.exception('')
|
||||
return 10
|
||||
|
||||
def check(self):
|
||||
try:
|
||||
if not self.check_is_needed():
|
||||
@ -2303,18 +2323,18 @@ def desktop_services(argv):
|
||||
]
|
||||
t3 = float(t2[0].split(':')[1].strip()[:-1])
|
||||
t5 = any(['discharging' in o.lower() for o in t4])
|
||||
if t3 < 10 and t5:
|
||||
if t3 < self.percentage_critical and t5:
|
||||
logging.error(json.dumps(dict(
|
||||
msg='too low', t3=t3, t5=t5
|
||||
)))
|
||||
subprocess.check_call(['systemctl', 'suspend'])
|
||||
elif t3 < 15 and t5:
|
||||
elif t3 < self.percentage_low and t5:
|
||||
msg = 'battery near low'
|
||||
logging.error(json.dumps(dict(
|
||||
msg=msg, t3=t3, t5=t5
|
||||
)))
|
||||
subprocess.check_call([
|
||||
'notify-send', '-t', '%d' % (5 * 1000), msg
|
||||
'notify-send', '-t', '%d' % (5 * 1000), msg, '% 5.2f' % t3,
|
||||
])
|
||||
else:
|
||||
pass
|
||||
|
Loading…
Reference in New Issue
Block a user