From 80db09037a96b7887c65f48e62d9ba3bc8cb5ba8 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Mon, 11 Jul 2022 13:19:10 +0530 Subject: aborting realtime-stats feature due to heavy RAM consumption so log-files get updated at event (when user changes window) --- src/Watcher/afk.py | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) (limited to 'src/Watcher/afk.py') 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) -- cgit v1.2.3