From 250938a63a930abf09af990ceaf46f5344e0f193 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Mon, 24 Jul 2017 17:52:24 +0200 Subject: [PATCH] i --- herbstluftwm/autostart | 1 + herbstluftwm/hl_status_deamon.py | 38 +++++++++++++++++++++++++++++++- zshrc | 7 +++--- 3 files changed, 42 insertions(+), 4 deletions(-) diff --git a/herbstluftwm/autostart b/herbstluftwm/autostart index b537cde..6309914 100755 --- a/herbstluftwm/autostart +++ b/herbstluftwm/autostart @@ -60,6 +60,7 @@ hc keybind $Mod-q close #spawn shit hc keybind $Mod-Return spawn urxvt +hc keybind $Mod-y spawn urxvt #easier to press with one hand hc keybind $Mod-Shift-Return spawn ~/.config/herbstluftwm/hl_start_urxvt_cwd.py hc keybind $Mod-i spawn urxvt -e nohup zsh -c "chromium &" #need to reliably use the zshconf chromium if [[ $HOST =~ atlantis* ]]; then diff --git a/herbstluftwm/hl_status_deamon.py b/herbstluftwm/hl_status_deamon.py index 9e26b60..f5d8da4 100755 --- a/herbstluftwm/hl_status_deamon.py +++ b/herbstluftwm/hl_status_deamon.py @@ -5,7 +5,7 @@ import time import sys import subprocess from hl_panel_content import color_panel -from hl_utils import error, is_cip, shexec, color_remove, hlpath +from hl_utils import error, is_cip, shexec, color_remove, hlpath, is_laptop RED = 0xff0000 GREEN = 0x32CD32 @@ -41,13 +41,49 @@ def vpn_status(): with open(vpn_path,'w+') as g: g.write(out_vpn) +def battery(): + try: + bat = hl_utils.shexec("acpi -b") + if bat == '': + return color_panel("BATTERY FAILURE",RED) + bat = re.compile(r'Battery [0-9]+: ').sub('',bat) + plain = int(bat.split('%')[0][-3:].rstrip('%').lstrip(',')) + + #cur_time = [bat.split('%, ')[1].split(' ')[0].split(':')] + + if plain > 10: + plain += BAT_COLOR_OFFSET + + if bat.startswith("Charging"): + return color_panel("Charging",GREEN,seper=False) + color_panel(bat.lstrip("Charging ,").strip('\n'),get_color(plain,0,100)) + elif bat.startswith("Full") or bat.startswith('Unknown'): + return color_panel("On Supply and fully charged",GREEN) + elif plain <= 1: + return color_panel(">>>>>>>>>>>>>>>> --------------- WARNING BATTER FAILURE IMMINENT --------------- <<<<<<<<<<<<<",RED) + elif bat.startswith("Discharging"): + return color_panel("Discharging",RED,seper=False) + color_panel(bat.lstrip("Discharging ,").strip('\n'),get_color(plain,0,100)) + else: + return color_panel(bat.strip('\n'),get_color(plain,0,100)) + except ValueError as e: + return color_panel(str(e),RED) + +def battery_status(): + if is_laptop: + with open(hlpatch("battery.log")) as g: + g.write(battery()) + + if __name__ == '__main__': #print('"'+sys.argv[-1]+'"') if sys.argv[-1]=='--refresh': vpn_status() pr_acct_status() + battery() sys.exit() while(True): vpn_status() pr_acct_status() + battery_status() time.sleep(30) + + diff --git a/zshrc b/zshrc index 6e0ca03..77800e8 100644 --- a/zshrc +++ b/zshrc @@ -169,8 +169,8 @@ alias mountcip="sshfs ik15ydit@faui00n.cs.fau.de:/ -o reconnect,idmap=user $CIP_ alias umountcip="fusermount -u $CIP_MOUNTPOINT" ## CONNECT Locally ## -alias -g atlantislaptop="ik15ydit@atlantislaptop.local" -alias -g atlantismedion="ik15ydit@atlantismedion.local" +#alias -g atlantislaptop="ik15ydit@atlantislaptop.local" +#alias -g atlantismedion="ik15ydit@atlantismedion.local" ## DIRECT TO CONFIG ## alias hlconf="vim ~/.config/herbstluftwm/autostart" @@ -197,6 +197,7 @@ fi if [[ $HOST =~ atlantis* ]]; then alias dual="xrandr --output DVI-I-2 --right-of DVI-I-1" alias shutown="/sbin/poweroff" + alias s2disk="sudo /usr/sbin/s2disk" fi if [[ $HOST == "atlantislaptop" ]]; then alias backlightctl="tee /sys/class/backlight/intel_backlight/brightness <<< $1" @@ -253,7 +254,7 @@ else PECO=/usr/bin/ fi -alias cfind='print -z $(cat ~/.config/zshhistory.log | $PECO/peco)' +alias cfind='print -z $(g/zshhistory.log | $PECO/peco)' hhs(){print -z "$(cat ~/.config/zshhistory.log | $PECO/peco)"} zle -N hhstest hhs bindkey ^R hhstest