fix: cleanup hc daemon scripts

This commit is contained in:
2023-01-06 14:59:55 +01:00
parent f53022b3c8
commit dc68a8a3fd
4 changed files with 12 additions and 27 deletions

View File

@@ -16,6 +16,6 @@ LOGINS_LOG = "logins.log"
BC_WORD_LOG = "bc.log"
BC_PAGE_LOG = "bcp.log"
BATTERY_CRITICAL = 3 # in %
BATTERY_CRITICAL = 10 # in %
BAT_WARNING_STR = ">>>>>>>>>>>>>>>> ------------ WARNING BATTER FAILURE IMMINENT ------------ <<<<<<<<<<<<<"
VALUES_KEPT = 10

View File

@@ -43,6 +43,13 @@ if pid==-1:
process = psutil.Process(pid)
for p in process.children(): #recursive=false
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()))
break
sys.exit()

View File

@@ -101,8 +101,8 @@ def battery():
plain = int(bat.split('%')[0][-3:].rstrip('%').lstrip(','))
## imediatelly return if full and on supply ##
if bat.startswith("Full") or bat.startswith('Unknown') or "Charging, 100%" in bat:
return hl_utils.color_panel("On Supply and fully charged",GREEN)
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)
## calculate average time remaining ##
sph = 60*60
@@ -180,26 +180,6 @@ def bc_words():
except subprocess.CalledProcessError:
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():
try:
@@ -234,7 +214,7 @@ def ip_status():
last_ip = ""
try:
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:
tmp = hl_utils.color_panel("No Internet Connection",RED)
with open(hl_utils.hlpath(IP_LOG),'w') as g:
@@ -248,8 +228,6 @@ def save():
ip_status()
#cip_logins()
trace_login()
bc_words()
bc_pages()
def trace_login():
if hl_utils.is_cip():

View File

@@ -28,7 +28,7 @@ def is_cip():
def is_laptop():
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):
with open(hlpath("herbstlog"),'a') as f: