From 255487a34700d6790a2771a177c16991caaca72f Mon Sep 17 00:00:00 2001 From: Waishnav Date: Tue, 14 Jun 2022 02:28:14 +0530 Subject: Ubuntu error solved of getting active window; --- src/Watcher/get_windows.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/Watcher/get_windows.py b/src/Watcher/get_windows.py index 6b1960f..6e7b3f2 100755 --- a/src/Watcher/get_windows.py +++ b/src/Watcher/get_windows.py @@ -1,16 +1,12 @@ import os import time -class window: - def __init__(self, class_name, title_name): - self.class_name = class_name - self.title_name = title_name - # get classname of app that user working on def active_window(): - # running bash command and storing result as a string - active_window = os.popen("xdotool getwindowfocus getwindowclassname").read() - active_window = active_window[0:-1] + # above command gives error on ubuntu cause of xdotool version is too old there while on arch it works +# active_window = os.popen("xdotool getwindowfocus getwindowclassname").read() + active_window_id = os.popen("xdotool getactivewindow").read()[:-1] + active_window = os.popen("xprop -id "+ str(active_window_id) +" | grep CLASS").read()[18::].split(",")[1].replace('''"''', "") return active_window # get title name of app that user working on -- cgit v1.2.3