From cc46840f2ab45402b1dfc0be264bed8242747bbf Mon Sep 17 00:00:00 2001 From: Sheppy Date: Fri, 24 Mar 2017 14:46:59 +0100 Subject: [PATCH] fixed some problems after stretch update --- herbstluftwm/hl_utils.py | 2 +- herbstluftwm/panel.sh | 2 +- herbstluftwm/panel_content.py | 18 ++++++++++++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/herbstluftwm/hl_utils.py b/herbstluftwm/hl_utils.py index b9781db..e939c33 100755 --- a/herbstluftwm/hl_utils.py +++ b/herbstluftwm/hl_utils.py @@ -13,7 +13,7 @@ def color_remove(s): return re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]').sub('',s) def shexec(s): - return subprocess.check_output(shlex.split(s)).decode() + return subprocess.check_output(shlex.split(s),shell=True).decode() def is_cip(): u = os.uname() diff --git a/herbstluftwm/panel.sh b/herbstluftwm/panel.sh index 2445c7f..8998e2e 100755 --- a/herbstluftwm/panel.sh +++ b/herbstluftwm/panel.sh @@ -118,7 +118,7 @@ hc pad $monitor $panel_height echo -n "^bg()^fg() ${windowtitle//^/^^}" ####################### Interface to python layer ######################### - right="$($HOME/.config/herbstluftwm/panel_content.py) $date" + right="30. Mai 14 Kobras |$($HOME/.config/herbstluftwm/panel_content.py) $date" right_text_only=$(echo -n "$right" | sed 's.\^[^(]*([^)]*)..g') # get width of right aligned text.. and add some space.. diff --git a/herbstluftwm/panel_content.py b/herbstluftwm/panel_content.py index ae28ebc..10e9717 100755 --- a/herbstluftwm/panel_content.py +++ b/herbstluftwm/panel_content.py @@ -56,6 +56,7 @@ def get_color(nr,start,end): def guthaben(): + guthaben = '' if hl_utils.is_cip(): tmp = -1 with open(hl_utils.hlpath("pracct.log")) as f: @@ -65,13 +66,15 @@ def guthaben(): guthaben = color_panel(guthaben,col) return guthaben; + def battery(): if hl_utils.is_laptop(): try: - bat = hl_utils.shexec("acpi -b | sed -r 's/Battery [0-9]+: //") - return color_panel(bat,get_color(int(bar.rstrip('%')),0,100)) - except(ValueError): - return color_panel("acpi or sed not in path",RED) + bat = hl_utils.shexec("acpi -b") + bat = re.compile(r'Battery [0-9]+: ').sub('',bat) + return color_panel(bat.strip('\n'),get_color(int(bat.split('%')[0][-2:].rstrip('%')),0,100)) + except ValueError as e: + return color_panel(str(e),RED) else: return "" @@ -96,5 +99,8 @@ def irc(): ret_string = "MSG FROM: "+user+"-> "+msg.rstrip('\n')+" - [ "+str(len(tmp))+" total ]" return color_panel(ret_string,RED) except(IOError): - return "" -print(irc(),guthaben(),battery()) + pass + else: + return '' + +print(irc(),guthaben(),battery(),sep='')