mirror of
https://github.com/FAUSheppy/config
synced 2025-12-06 23:21:34 +01:00
fix: cleanup hc daemon scripts
This commit is contained in:
@@ -16,6 +16,6 @@ LOGINS_LOG = "logins.log"
|
|||||||
BC_WORD_LOG = "bc.log"
|
BC_WORD_LOG = "bc.log"
|
||||||
BC_PAGE_LOG = "bcp.log"
|
BC_PAGE_LOG = "bcp.log"
|
||||||
|
|
||||||
BATTERY_CRITICAL = 3 # in %
|
BATTERY_CRITICAL = 10 # in %
|
||||||
BAT_WARNING_STR = ">>>>>>>>>>>>>>>> ------------ WARNING BATTER FAILURE IMMINENT ------------ <<<<<<<<<<<<<"
|
BAT_WARNING_STR = ">>>>>>>>>>>>>>>> ------------ WARNING BATTER FAILURE IMMINENT ------------ <<<<<<<<<<<<<"
|
||||||
VALUES_KEPT = 10
|
VALUES_KEPT = 10
|
||||||
|
|||||||
@@ -43,6 +43,13 @@ if pid==-1:
|
|||||||
process = psutil.Process(pid)
|
process = psutil.Process(pid)
|
||||||
for p in process.children(): #recursive=false
|
for p in process.children(): #recursive=false
|
||||||
if p.name() in ['zsh','bash']:
|
if p.name() in ['zsh','bash']:
|
||||||
|
|
||||||
|
# check for ssh #
|
||||||
|
for sp in p.children(recursive=True):
|
||||||
|
print(sp.name())
|
||||||
|
if sp.name() == 'ssh':
|
||||||
|
print(sp)
|
||||||
|
|
||||||
subprocess.Popen(shlex.split('urxvt -cd ' + p.cwd()))
|
subprocess.Popen(shlex.split('urxvt -cd ' + p.cwd()))
|
||||||
break
|
break
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
@@ -101,8 +101,8 @@ def battery():
|
|||||||
plain = int(bat.split('%')[0][-3:].rstrip('%').lstrip(','))
|
plain = int(bat.split('%')[0][-3:].rstrip('%').lstrip(','))
|
||||||
|
|
||||||
## imediatelly return if full and on supply ##
|
## imediatelly return if full and on supply ##
|
||||||
if bat.startswith("Full") or bat.startswith('Unknown') or "Charging, 100%" in bat:
|
if bat.startswith("Full") or bat.startswith('Unknown') or "100%" in bat or "99%" in bat:
|
||||||
return hl_utils.color_panel("On Supply and fully charged",GREEN)
|
return hl_utils.color_panel("On Supply and fully charged", GREEN)
|
||||||
|
|
||||||
## calculate average time remaining ##
|
## calculate average time remaining ##
|
||||||
sph = 60*60
|
sph = 60*60
|
||||||
@@ -180,26 +180,6 @@ def bc_words():
|
|||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def bc_pages():
|
|
||||||
try:
|
|
||||||
arr = hl_utils.shexec("pdftk {} dump_data".format(\
|
|
||||||
hl_utils.hlpath(".bcpdf",use_hostname=False)))
|
|
||||||
arr = arr.split("\n")
|
|
||||||
lol = "lolcannon"
|
|
||||||
for el in arr:
|
|
||||||
if "NumberOfPages" in el:
|
|
||||||
try:
|
|
||||||
with open(hl_utils.hlpath(BC_PAGE_LOG),'r') as f:
|
|
||||||
if int(f.read()) == int(el):
|
|
||||||
break
|
|
||||||
except:
|
|
||||||
pass
|
|
||||||
lol = el
|
|
||||||
break
|
|
||||||
with open(hl_utils.hlpath(BC_PAGE_LOG),"w") as g:
|
|
||||||
g.write(el.split()[1])
|
|
||||||
except subprocess.CalledProcessError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
def vpn_status():
|
def vpn_status():
|
||||||
try:
|
try:
|
||||||
@@ -234,7 +214,7 @@ def ip_status():
|
|||||||
last_ip = ""
|
last_ip = ""
|
||||||
try:
|
try:
|
||||||
hl_utils.shexec("wget --timeout=2 -O- --quiet https://wwwcip.cs.fau.de/")
|
hl_utils.shexec("wget --timeout=2 -O- --quiet https://wwwcip.cs.fau.de/")
|
||||||
tmp = hl_utils.color_panel("AtlantisHQ Unreachable",RED)
|
tmp = hl_utils.color_panel("Online (ipcheck unreachable)",GREEN)
|
||||||
except:
|
except:
|
||||||
tmp = hl_utils.color_panel("No Internet Connection",RED)
|
tmp = hl_utils.color_panel("No Internet Connection",RED)
|
||||||
with open(hl_utils.hlpath(IP_LOG),'w') as g:
|
with open(hl_utils.hlpath(IP_LOG),'w') as g:
|
||||||
@@ -248,8 +228,6 @@ def save():
|
|||||||
ip_status()
|
ip_status()
|
||||||
#cip_logins()
|
#cip_logins()
|
||||||
trace_login()
|
trace_login()
|
||||||
bc_words()
|
|
||||||
bc_pages()
|
|
||||||
|
|
||||||
def trace_login():
|
def trace_login():
|
||||||
if hl_utils.is_cip():
|
if hl_utils.is_cip():
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ def is_cip():
|
|||||||
|
|
||||||
def is_laptop():
|
def is_laptop():
|
||||||
u = os.uname()
|
u = os.uname()
|
||||||
return "laptop" in u.nodename or "atlantismedion" in u.nodename
|
return "laptop" in u.nodename or "atlantismedion" in u.nodename or "atlantispad" in u.nodename
|
||||||
|
|
||||||
def error(s):
|
def error(s):
|
||||||
with open(hlpath("herbstlog"),'a') as f:
|
with open(hlpath("herbstlog"),'a') as f:
|
||||||
|
|||||||
Reference in New Issue
Block a user