mirror of
https://github.com/FAUSheppy/config
synced 2025-12-07 23:41:34 +01:00
Improved VPN detection
This commit is contained in:
@@ -38,8 +38,8 @@ if [[ "$HOST" == "atlantislaptop" ]]; then
|
|||||||
xautolock -time 15 -locker /home/ik15ydit/.config/i3lock/piclock.sh &
|
xautolock -time 15 -locker /home/ik15ydit/.config/i3lock/piclock.sh &
|
||||||
/usr/bin/dunst &
|
/usr/bin/dunst &
|
||||||
hc keybind $Mod-o spawn /bin/bash -c "/home/ik15ydit/.config/i3lock/piclock.sh & systemctl hibernate"
|
hc keybind $Mod-o spawn /bin/bash -c "/home/ik15ydit/.config/i3lock/piclock.sh & systemctl hibernate"
|
||||||
hc keybind $Mod-c spawn /bin/bash -c "sudo /usr/bin/openvpn_cip.sh"
|
hc keybind $Mod-c spawn /bin/bash -c "sudo /usr/bin/openvpn_cip.sh & ~/.config/herbstluftwm/hl_status_deamon.py --refresh"
|
||||||
hc keybind $Mod-Shift-c spawn /bin/bash -c "sudo stopvpn.sh"
|
hc keybind $Mod-Shift-c spawn /bin/bash -c "sudo stopvpn.sh && ~/.config/herbstluftwm/hl_status_deamon.py --refresh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import sys
|
||||||
import subprocess
|
import subprocess
|
||||||
from hl_panel_content import color_panel
|
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
|
||||||
@@ -11,7 +12,7 @@ GREEN = 0x32CD32
|
|||||||
YELLOW = 0xffff00
|
YELLOW = 0xffff00
|
||||||
|
|
||||||
#Druckerguthaben
|
#Druckerguthaben
|
||||||
def pr_acct_status()_
|
def pr_acct_status():
|
||||||
if is_cip():
|
if is_cip():
|
||||||
path = hlpath("pracct.log")
|
path = hlpath("pracct.log")
|
||||||
out = color_remove(shexec("pr_acct").split("\n")[0]).split(' ')[-1]
|
out = color_remove(shexec("pr_acct").split("\n")[0]).split(' ')[-1]
|
||||||
@@ -23,24 +24,30 @@ def vpn_status():
|
|||||||
out_vpn = subprocess.check_output(["ps","-ef"]).decode().split('\n')
|
out_vpn = subprocess.check_output(["ps","-ef"]).decode().split('\n')
|
||||||
#filter(lambda x: not 'openvpn' in x,out_vpn)
|
#filter(lambda x: not 'openvpn' in x,out_vpn)
|
||||||
ret = 0
|
ret = 0
|
||||||
|
#worst case thats about 1k lines
|
||||||
for l in out_vpn:
|
for l in out_vpn:
|
||||||
if 'openvpn' in l:
|
if 'openvpn' in l and not 'sudo' in l and not 'grep' in l and not 'cip.sh' in l:
|
||||||
ret += 1;
|
ret += 1;
|
||||||
print(ret)
|
#print(ret)
|
||||||
if ret <= 1:
|
if ret == 0:
|
||||||
out_vpn = color_panel("VPN: Link Down",RED)
|
out_vpn = color_panel("VPN: Link Down",RED)
|
||||||
elif ret <= 3:
|
elif ret == 1:
|
||||||
out_vpn = color_panel("VPN: In Use",GREEN)
|
out_vpn = color_panel("VPN: In Use",GREEN)
|
||||||
elif ret >= 4:
|
elif ret > 1:
|
||||||
out_vpn = color_panel("multiple VPNs connected",YELLOW)
|
out_vpn = color_panel("multiple VPNs connected",YELLOW)
|
||||||
else:
|
else:
|
||||||
out_vpn = color_panel("VPN: WTF alles kaputt",RED)
|
out_vpn = color_panel("VPN: ret was "+str(ret)+" ??",RED)
|
||||||
#print(out_vpn)
|
#print(out_vpn)
|
||||||
with open(vpn_path,'w+') as g:
|
with open(vpn_path,'w+') as g:
|
||||||
g.write(out_vpn)
|
g.write(out_vpn)
|
||||||
time.sleep(30)
|
|
||||||
|
|
||||||
if __name__ = '__main__':
|
if __name__ == '__main__':
|
||||||
|
#print('"'+sys.argv[-1]+'"')
|
||||||
|
if sys.argv[-1]=='--refresh':
|
||||||
|
vpn_status()
|
||||||
|
pr_acct_status()
|
||||||
|
sys.exit()
|
||||||
while(True):
|
while(True):
|
||||||
vpn_status()
|
vpn_status()
|
||||||
pr_acct_status()
|
pr_acct_status()
|
||||||
|
time.sleep(30)
|
||||||
|
|||||||
Reference in New Issue
Block a user