diff options
author | 2022-07-12 16:17:39 +0530 | |
---|---|---|
committer | 2022-07-12 16:17:39 +0530 | |
commit | 27365936982c5e3fcab51f5d0f93ff4feea687ef (patch) | |
tree | 0047bff5bbd5193d7d86b2ac49c7df3fde6cad22 /src/Watcher/get_windows.py | |
parent | 80db09037a96b7887c65f48e62d9ba3bc8cb5ba8 (diff) | |
download | shopno-os-log-sync-27365936982c5e3fcab51f5d0f93ff4feea687ef.tar.gz shopno-os-log-sync-27365936982c5e3fcab51f5d0f93ff4feea687ef.zip |
Removing EWMH module as a dependancy (causing more RAM consumption over the time)
Diffstat (limited to 'src/Watcher/get_windows.py')
-rwxr-xr-x | src/Watcher/get_windows.py | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py index 8cfbc70..65e8a93 100755 --- a/src/Watcher/get_windows.py +++ b/src/Watcher/get_windows.py @@ -1,33 +1,27 @@ import os import time from afk import get_afk_status -from ewmh import EWMH # get title name of app that user working on def active_window_title(): - try: - win = EWMH().getActiveWindow() - active_window_title = win.get_wm_name() - except AttributeError: - active_window_title = "unknown" + active_window_title = os.popen("""xprop -id $(xprop -root _NET_ACTIVE_WINDOW | cut -d ' ' -f 5) WM_NAME | sed -nr 's/.*= "(.*)"$/\1/p'""").read()[:-1] + if "XGetWindowProperty[_NET_ACTIVE_WINDOW] failed" in active_window_title: + active_window_title = "" + if "\n" in active_window_title: + active_window_title = "Unknown" active_window_title = active_window_title.capitalize() return active_window_title # get classname of app that user working on def active_window(): - try: - win = EWMH().getActiveWindow() - active_window = win.get_wm_class()[1] - except AttributeError: - active_window = "unknown" - - if len(active_window) > 20: - active_window = "unknown" - elif "\n" in active_window: - active_window = "unknown" - active_window = active_window.capitalize() + active_window = os.popen("xprop -id $(xdotool getactivewindow) | grep CLASS | awk '{print $4}'").read()[:-1].replace('''"''', "") + if "XGetWindowProperty[_NET_ACTIVE_WINDOW] failed" in active_window: + active_window = "" + if "\n" in active_window: + active_window = "Unknown" # check whether user is using nvim or vim + active_window = active_window.capitalize() 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: |