diff options
author | 2022-07-11 13:19:10 +0530 | |
---|---|---|
committer | 2022-07-11 13:19:10 +0530 | |
commit | 80db09037a96b7887c65f48e62d9ba3bc8cb5ba8 (patch) | |
tree | 7f7d341b73287eddeb3413b0602592ef476dda9a /src/Watcher/afk.py | |
parent | f38fa81c08795f3160fd1c0320840a5ec931304e (diff) | |
download | shopno-os-log-sync-80db09037a96b7887c65f48e62d9ba3bc8cb5ba8.tar.gz shopno-os-log-sync-80db09037a96b7887c65f48e62d9ba3bc8cb5ba8.zip |
aborting realtime-stats feature due to heavy RAM consumption so log-files get updated at event (when user changes window)
Diffstat (limited to 'src/Watcher/afk.py')
-rwxr-xr-x | src/Watcher/afk.py | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/src/Watcher/afk.py b/src/Watcher/afk.py index e309231..4f2b1f7 100755 --- a/src/Watcher/afk.py +++ b/src/Watcher/afk.py @@ -1,14 +1,19 @@ import os -def IsAFK(): - time_since_last_input = int(os.popen("xprintidle").read()) - if time_since_last_input >= 300000: # 3min no input == AFK - video_playback = os.popen("""pacmd list-sink-inputs | grep -w state | grep -i 'CORKED'""").read() - # if playback is not running as well as user is AFK - if "CORKED" in video_playback: - return True - # if playback is running is background as well as user is AFK - else: - return False + +# checks if currently in afk mode, only returns true once +def get_afk_status(afk_active, timeout): + if (is_afk(timeout)): + return True + elif returned_from_afk(afk_active, timeout): + return True else: return False +def returned_from_afk(afk_active, timeout): + has_returned = (afk_active and not (is_afk(timeout))) + return has_returned + +def is_afk(timeout): + timeout = timeout * 60 * 1000 + #If the AFK feature is installed + return (int((os.popen("xprintidle").read())) > timeout) |