aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/critical_hibernate.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/critical_hibernate.py')
-rwxr-xr-xscripts/critical_hibernate.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/scripts/critical_hibernate.py b/scripts/critical_hibernate.py
index f7128e2..a51a97c 100755
--- a/scripts/critical_hibernate.py
+++ b/scripts/critical_hibernate.py
@@ -39,8 +39,9 @@ try:
batfd = os.open(sysfs_path, os.O_RDONLY)
print('monitoring %s (threshold %d%%)' % (sysfs_path, threshold))
while True:
- uevent_dict = dict((e.split(b'=')
- for e in os.pread(batfd, 1024, 0).split()))
+ uevent_dict = dict((tuple(x.strip() for x in e.split(b'='))
+ for e in os.pread(batfd, 1024, 0).split(b'\n')
+ if e))
capacity = int(uevent_dict[b'POWER_SUPPLY_CAPACITY'])
status = uevent_dict[b'POWER_SUPPLY_STATUS']
if status == b'Discharging' and capacity <= threshold: