Browse Source

Fix sleep problem?

master
Burathar 4 years ago
parent
commit
f1cc130646
  1. 10
      bin/xscreensaver_yubilock.py

10
bin/xscreensaver_yubilock.py

@ -51,11 +51,9 @@ def execute(command: str, shell_on: bool = False, background: bool = False): @@ -51,11 +51,9 @@ def execute(command: str, shell_on: bool = False, background: bool = False):
def screensaver_running():
graphic_program_instances = execute(f"{script_dir}/kill_screensaver_graphic_program.sh -d | grep graphic_processes | wc -l", shell_on=True)
return int(graphic_program_instances) > 0
def just_woke_up():
seconds_since_wakeup = execute(f"{script_dir}/seconds_since_wakeup.sh", shell_on=True)
return int(seconds_since_wakeup) < 60
if int(graphic_program_instances) > 0: return True
if execute(f"DISPLAY=:0 xscreensaver-command -time | grep 'screen locked' >/dev/null 2>&1", shell_on=True): return True
return False
def lock_screen():
if args.dummy :
@ -102,7 +100,7 @@ def get_yubikey_serials() -> int: @@ -102,7 +100,7 @@ def get_yubikey_serials() -> int:
def update_lock_state():
if any(serial in yubikey_serials for serial in get_yubikey_serials()):
if screensaver_running() or just_woke_up():
if screensaver_running():
logger.debug('screen will be unlocked')
unlock_screen()
else:

Loading…
Cancel
Save