mirror of
https://github.com/FAUSheppy/config
synced 2025-12-11 00:58:33 +01:00
Added VPN-Status in panel
This commit is contained in:
@@ -71,6 +71,13 @@ def guthaben():
|
|||||||
guthaben = color_panel(guthaben,col)
|
guthaben = color_panel(guthaben,col)
|
||||||
return guthaben;
|
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():
|
def battery():
|
||||||
if hl_utils.is_laptop():
|
if hl_utils.is_laptop():
|
||||||
@@ -126,4 +133,4 @@ def irc():
|
|||||||
else:
|
else:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
print(guthaben(),battery(),sep='')
|
print(vpn(),guthaben(),battery(),sep='')
|
||||||
|
|||||||
@@ -2,14 +2,38 @@
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
import subprocess
|
||||||
|
from hl_panel_content.py 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
|
||||||
|
|
||||||
|
RED = 0xff0000
|
||||||
|
GREEN = 0x32CD32
|
||||||
|
YELLOW = 0xffff00
|
||||||
|
|
||||||
#Druckerguthaben
|
#Druckerguthaben
|
||||||
if is_cip():
|
while(True):
|
||||||
while(True):
|
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]
|
||||||
with open(path,'w+') as f:
|
with open(path,'w+') as f:
|
||||||
f.write(out)
|
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)
|
time.sleep(30)
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
Reference in New Issue
Block a user