diff options
author | 2022-07-18 16:41:53 +0530 | |
---|---|---|
committer | 2022-07-18 16:41:53 +0530 | |
commit | fbe30df91fd15dd52c31a1237c9a00c24763f509 (patch) | |
tree | 189446929df9dec5b11e72f0a0e7c8a1ed7f6956 /src/Watcher/get_windows.py | |
parent | c927f1f3694b90573373e07230730ec9b8e6a18c (diff) | |
download | shopno-os-log-sync-fbe30df91fd15dd52c31a1237c9a00c24763f509.tar.gz shopno-os-log-sync-fbe30df91fd15dd52c31a1237c9a00c24763f509.zip |
adding -s option to start watch_log function | active_window function updated to reduce error to get home-screen
Diffstat (limited to 'src/Watcher/get_windows.py')
-rwxr-xr-x | src/Watcher/get_windows.py | 7 |
1 files changed, 5 insertions, 2 deletions
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 |