This commit is contained in:
Sheppy
2017-09-29 02:49:38 +02:00
parent 23cfa22aa9
commit 00d5087503
3 changed files with 27 additions and 34 deletions

View File

@@ -86,6 +86,12 @@ def vpn():
tmp = ' '+tmp tmp = ' '+tmp
return tmp; return tmp;
def ip():
with open(hl_utils.hlpath("ip.log")) as f:
tmp = f.read()
tmp = ' '+tmp
return tmp;
def battery(): def battery():
if hl_utils.is_laptop(): if hl_utils.is_laptop():
try: try:
@@ -115,29 +121,6 @@ def battery():
else: else:
return "" return ""
def irc():
if hl_utils.is_cip():
ret_string = "IRC ERROR"
try:
fname = hl_utils.hlpath("irc.log")
tmp = []
with open(fname) as f:
for l in f:
tmp+=[l]
if len(tmp) == 0:
return ""
msg = " ".join(tmp[-1].split(" ")[2:])[:50]
user = tmp[-1].split(" ")[1][:15]
if not "%push" in msg:
return ""
pattern = re.compile("\^+[fb]g[(]+#[0-9]+[)]+")
msg = re.sub(pattern,"",msg)
user = re.sub(pattern,"",user)
ret_string = "MSG FROM: "+user+"-> "+msg.rstrip('\n')+" - [ "+str(len(tmp))+" total ]"
return color_panel(ret_string,RED)
except(IOError):
pass
else:
return ''
if __name__ == "__main__": if __name__ == "__main__":
print(vpn(),guthaben(),battery(),sep='') print(ip(),vpn(),guthaben(),battery(),sep='')

View File

@@ -4,12 +4,15 @@ import sys
import time import time
import sys import sys
import subprocess import subprocess
from hl_panel_content import color_panel from hl_panel_content import color_panel, get_color
from hl_utils import error, is_cip, shexec, color_remove, hlpath, is_laptop from hl_utils import error, is_cip, shexec, color_remove, hlpath, is_laptop
import re
RED = 0xff0000 RED = 0xff0000
GREEN = 0x32CD32 GREEN = 0x32CD32
YELLOW = 0xffff00 YELLOW = 0xffff00
BAT_COLOR_OFFSET = 10
#Druckerguthaben #Druckerguthaben
def pr_acct_status(): def pr_acct_status():
@@ -43,7 +46,7 @@ def vpn_status():
def battery(): def battery():
try: try:
bat = hl_utils.shexec("acpi -b") bat = shexec("acpi -b")
if bat == '': if bat == '':
return color_panel("BATTERY FAILURE",RED) return color_panel("BATTERY FAILURE",RED)
bat = re.compile(r'Battery [0-9]+: ').sub('',bat) bat = re.compile(r'Battery [0-9]+: ').sub('',bat)
@@ -69,21 +72,28 @@ def battery():
def battery_status(): def battery_status():
if is_laptop: if is_laptop:
with open(hlpatch("battery.log")) as g: with open(hlpath("battery.log"),'w') as g:
g.write(battery()) g.write(battery())
def ip_status():
with open(hlpath("ip.log"),'w') as g:
p="Public IP: "
try:
tmp=color_panel(p+shexec("wget --timeout=3 -O- --quiet https://atlantishq.de/ipcheck"),GREEN)
except:
tmp=color_panel("Offline",RED)
g.write(tmp)
if __name__ == '__main__': if __name__ == '__main__':
#print('"'+sys.argv[-1]+'"') #print('"'+sys.argv[-1]+'"')
if sys.argv[-1]=='--refresh':
vpn_status()
pr_acct_status()
battery()
sys.exit()
while(True): while(True):
vpn_status() vpn_status()
pr_acct_status() pr_acct_status()
battery_status() battery_status()
ip_status()
if sys.argv[-1]=='--refresh':
break
time.sleep(30) time.sleep(30)

View File

@@ -13,7 +13,7 @@ def color_remove(s):
return re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]').sub('',s) return re.compile(r'(\x9B|\x1B\[)[0-?]*[ -\/]*[@-~]').sub('',s)
def shexec(s): def shexec(s):
return subprocess.check_output(shlex.split(s),shell=True).decode() return subprocess.check_output(shlex.split(s),shell=False).decode()
def is_cip(): def is_cip():
u = os.uname() u = os.uname()