Waishnav / Watcher

Minimal open source Screen-Time Tracker for Linux
https://watcher-org.github.io/Watcher
MIT License
139 stars 11 forks source link

Update get_windows.py #14

Closed augustin64 closed 2 years ago

augustin64 commented 2 years ago

Fix an IndexError happening when going on homescreen on GNOME desktop causing the entire program to crash.

Waishnav commented 2 years ago

Hey, thanks for using Watcher, talking about PR as I don't use ubuntu so can you confirm that your code fixes this issue by providing a video of Watcher working perfectly?

augustin64 commented 2 years ago

I don't think providing a video to confirm that watcher works is needed due to the small diff. Here is the error I had before modifying the code:

Traceback (most recent call last):
  File "/usr/local/bin/watcher", line 47, in <module>
    x.log_creation()
  File "/usr/share/Watcher/watch_log.py", line 57, in log_creation
    if (x.is_window_changed(previous_window, afk, afkTimeout) and not afk):
  File "/usr/share/Watcher/get_windows.py", line 47, in is_window_changed
    b = active_window()
  File "/usr/share/Watcher/get_windows.py", line 22, in active_window
    active_window = os.popen("xprop -id $(xdotool getwindowfocus) | grep CLASS ").read()[19:-1].replace('''"''', "").split(", ")[1]
IndexError: list index out of range

Happening on stock GNOME on Arch Linux.