From fbe30df91fd15dd52c31a1237c9a00c24763f509 Mon Sep 17 00:00:00 2001 From: Waishnav Date: Mon, 18 Jul 2022 16:41:53 +0530 Subject: adding -s option to start watch_log function | active_window function updated to reduce error to get home-screen --- src/Watcher/get_windows.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/Watcher') diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py index 85e9bd8..2831833 100755 --- a/src/Watcher/get_windows.py +++ b/src/Watcher/get_windows.py @@ -14,7 +14,11 @@ def active_window_title(): # get classname of app that user working on def active_window(): - active_window = os.popen("xprop -id $(xdotool getactivewindow) | grep CLASS ").read()[19:-1].replace('''"''', "").split(", ")[0] + actv_id = os.popen("xdotool getwindowfocus").read()[:-1] + if len(actv_id) == 4: + active_window = "" + else: + active_window = os.popen("xprop -id $(xdotool getwindowfocus) | grep CLASS ").read()[19:-1].replace('''"''', "").split(", ")[1] if "XGetWindowProperty[_NET_ACTIVE_WINDOW] failed" in active_window: active_window = "" @@ -49,7 +53,6 @@ def is_window_changed(a, afk, timeout): return result -print(active_window()) ### what to do after window get change I've to append one line in csv data file in following format ### opened-time closed-time time-spent window_class_name window_title_name -- cgit v1.2.3