From 9b7c4585e4b3e3ec8bbf4d8ad030d9fe1281b3a1 Mon Sep 17 00:00:00 2001 From: Sheppy Date: Mon, 22 May 2017 18:06:48 +0200 Subject: [PATCH] Fixed VPN status --- herbstluftwm/hl_panel_content.py | 9 +++++---- herbstluftwm/hl_status_deamon.py | 14 ++++++++------ 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/herbstluftwm/hl_panel_content.py b/herbstluftwm/hl_panel_content.py index 1c0f9fc..86358e7 100755 --- a/herbstluftwm/hl_panel_content.py +++ b/herbstluftwm/hl_panel_content.py @@ -76,7 +76,8 @@ def vpn(): if not hl_utils.is_cip(): tmp = -1 with open(hl_utils.hlpath("vpn_status.log")) as f: - tmp = float(f.read()); + tmp = f.read() + tmp = ' '+tmp return tmp; def battery(): @@ -95,7 +96,7 @@ def battery(): 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"): + 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) @@ -132,5 +133,5 @@ def irc(): pass else: return '' - -print(vpn(),guthaben(),battery(),sep='') +if __name__ == "__main__": + print(vpn(),guthaben(),battery(),sep='') diff --git a/herbstluftwm/hl_status_deamon.py b/herbstluftwm/hl_status_deamon.py index db4719f..e272c84 100755 --- a/herbstluftwm/hl_status_deamon.py +++ b/herbstluftwm/hl_status_deamon.py @@ -3,7 +3,7 @@ import os import sys import time import subprocess -from hl_panel_content.py import color_panel +from hl_panel_content import color_panel from hl_utils import error, is_cip, shexec, color_remove, hlpath RED = 0xff0000 @@ -27,12 +27,14 @@ while(True): ret += 1; print(ret) if ret <= 1: - out_vpn = color_panel("VPN DEACTIVATED",GREEN) - if ret == 2: - out_vpn = color_panel("VPN CONNECTED",RED) - if ret >= 3: + out_vpn = color_panel("VPN DEACTIVATED",RED) + elif ret <= 3: + out_vpn = color_panel("VPN CONNECTED",GREEN) + elif ret >= 4: out_vpn = color_panel("multiple VPNs connected",YELLOW) - print(out_vpn) + else: + out_vpn = color_panel("WTF VPN STATUS BROKEN",RED) + #print(out_vpn) with open(vpn_path,'w+') as g: g.write(out_vpn) time.sleep(30)