aboutsummaryrefslogtreecommitdiff
path: root/src/Watcher/get_windows.py
diff options
context:
space:
mode:
authorLibravatar Waishnav <waishnavdeore@gmail.com>2022-07-11 13:19:10 +0530
committerLibravatar Waishnav <waishnavdeore@gmail.com>2022-07-11 13:19:10 +0530
commit80db09037a96b7887c65f48e62d9ba3bc8cb5ba8 (patch)
tree7f7d341b73287eddeb3413b0602592ef476dda9a /src/Watcher/get_windows.py
parentf38fa81c08795f3160fd1c0320840a5ec931304e (diff)
downloadshopno-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/get_windows.py')
-rwxr-xr-xsrc/Watcher/get_windows.py33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py
index f895662..8cfbc70 100755
--- a/src/Watcher/get_windows.py
+++ b/src/Watcher/get_windows.py
@@ -1,12 +1,8 @@
import os
import time
+from afk import get_afk_status
from ewmh import EWMH
-class window:
- def __init__(self, class_name, title_name):
- self.class_name = class_name
- self.title_name = title_name
-
# get title name of app that user working on
def active_window_title():
try:
@@ -35,21 +31,30 @@ def active_window():
aw_title = active_window_title()
terminals = ["Kitty", "Alacritty", "Terminator", "Tilda", "Guake", "Yakuake", "Roxterm", "Eterm", "Rxvt", "Xterm", "Tilix", "Lxterminal", "Konsole", "St", "Gnome-terminal", "Xfce4-terminal", "Terminology", "Extraterm"]
if active_window in terminals:
- if "Nvim" in aw_title:
- active_window = "NeoVim"
- elif "Vim" in aw_title:
- active_window = "Vim"
+ try:
+ if "Nvim" in aw_title:
+ active_window = "NeoVim"
+ elif "Vim" in aw_title:
+ active_window = "Vim"
+ except TypeError:
+ None
return active_window
# returns true if user has move to next app which is not the same as previous
-def is_window_changed(a):
+def is_window_changed(a, afk, timeout):
result = False
- time.sleep(0.5)
- b = active_window()
- if a != b :
- result = True
+ while not(result):
+ time.sleep(1)
+ b = active_window()
+ if a != b :
+ result = True
+ elif get_afk_status(afk, timeout):
+ result = True
+ else:
+ result = False
return result
+
### 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