diff --git a/herbstluftwm/hl_panel_content.py b/herbstluftwm/hl_panel_content.py index abf7389..1c0f9fc 100755 --- a/herbstluftwm/hl_panel_content.py +++ b/herbstluftwm/hl_panel_content.py @@ -71,6 +71,13 @@ def guthaben(): guthaben = color_panel(guthaben,col) return guthaben; +def vpn(): + vpn = '' + if not hl_utils.is_cip(): + tmp = -1 + with open(hl_utils.hlpath("vpn_status.log")) as f: + tmp = float(f.read()); + return tmp; def battery(): if hl_utils.is_laptop(): @@ -126,4 +133,4 @@ def irc(): else: return '' -print(guthaben(),battery(),sep='') +print(vpn(),guthaben(),battery(),sep='') diff --git a/herbstluftwm/hl_status_deamon.py b/herbstluftwm/hl_status_deamon.py index 6c36aae..db4719f 100755 --- a/herbstluftwm/hl_status_deamon.py +++ b/herbstluftwm/hl_status_deamon.py @@ -2,14 +2,38 @@ import os import sys import time +import subprocess +from hl_panel_content.py import color_panel from hl_utils import error, is_cip, shexec, color_remove, hlpath +RED = 0xff0000 +GREEN = 0x32CD32 +YELLOW = 0xffff00 + #Druckerguthaben -if is_cip(): - while(True): +while(True): + if is_cip(): path = hlpath("pracct.log") out = color_remove(shexec("pr_acct").split("\n")[0]).split(' ')[-1] with open(path,'w+') as f: f.write(out) + if not is_cip(): + vpn_path = hlpath("vpn_status.log") + out_vpn = subprocess.check_output(["ps","-ef"]).decode().split('\n') + #filter(lambda x: not 'openvpn' in x,out_vpn) + ret = 0 + for l in out_vpn: + if 'openvpn' in l: + 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("multiple VPNs connected",YELLOW) + print(out_vpn) + with open(vpn_path,'w+') as g: + g.write(out_vpn) time.sleep(30) sys.exit()