mirror of
https://github.com/FAUSheppy/config
synced 2025-12-06 07:01:36 +01:00
fix: battery query crashes on missing history
This commit is contained in:
@@ -63,7 +63,7 @@ fi
|
|||||||
hc keybind $Mod-p spawn pavucontrol
|
hc keybind $Mod-p spawn pavucontrol
|
||||||
hc keybind $Mod-Shift-l spawn libreoffice
|
hc keybind $Mod-Shift-l spawn libreoffice
|
||||||
hc keybind $Mod-t spawn /bin/bash -c "LC_ALL=en_DK.utf8 && export LC_ALL && thunderbird"
|
hc keybind $Mod-t spawn /bin/bash -c "LC_ALL=en_DK.utf8 && export LC_ALL && thunderbird"
|
||||||
hc keybind $Mod-Shift-j spawn urxvt -e ssh -p 7022 sheppy@atlantishq.de -t 'tmux a -d'
|
hc keybind $Mod-Shift-j spawn urxvt -e ssh sheppy@irc-new.atlantishq.de -t 'tmux a -d'
|
||||||
hc keybind $Mod-e spawn rofi -combi-mode window,run -show combi -modi combi
|
hc keybind $Mod-e spawn rofi -combi-mode window,run -show combi -modi combi
|
||||||
hc keybind $Mod-Shift-e spawn rofi -show run
|
hc keybind $Mod-Shift-e spawn rofi -show run
|
||||||
hc keybind $Mod-u spawn /usr/bin/pulseaudio -k
|
hc keybind $Mod-u spawn /usr/bin/pulseaudio -k
|
||||||
|
|||||||
@@ -111,7 +111,11 @@ def battery():
|
|||||||
spm = 60
|
spm = 60
|
||||||
|
|
||||||
cur_time = bat.split('%, ')[1].split(' ')[0].split(':')
|
cur_time = bat.split('%, ')[1].split(' ')[0].split(':')
|
||||||
cur = int(cur_time[0]) * sph + int(cur_time[1]) * spm + int(cur_time[2])
|
cur = 0
|
||||||
|
try:
|
||||||
|
cur = int(cur_time[0]) * sph + int(cur_time[1]) * spm + int(cur_time[2])
|
||||||
|
except ValueError:
|
||||||
|
pass
|
||||||
|
|
||||||
global battery_average
|
global battery_average
|
||||||
global bat_prev
|
global bat_prev
|
||||||
@@ -120,6 +124,9 @@ def battery():
|
|||||||
bat_avg = "unkown"
|
bat_avg = "unkown"
|
||||||
else:
|
else:
|
||||||
bat_avg=int(sum(battery_average) / float(len(battery_average)))
|
bat_avg=int(sum(battery_average) / float(len(battery_average)))
|
||||||
|
|
||||||
|
if len(battery_average) > 100:
|
||||||
|
battery_average = battery_average[:-100]
|
||||||
|
|
||||||
## keep max 10 items in queue ##
|
## keep max 10 items in queue ##
|
||||||
if len(battery_average) > VALUES_KEPT:
|
if len(battery_average) > VALUES_KEPT:
|
||||||
|
|||||||
Reference in New Issue
Block a user