Coder Social home page Coder Social logo

activitywatch / aw-watcher-window Goto Github PK

View Code? Open in Web Editor NEW
80.0 10.0 49.0 349 KB

Cross-platform window watcher (for use with ActivityWatch)

License: Mozilla Public License 2.0

Makefile 1.34% Python 61.42% Swift 37.25%
quantified-self activitywatch activitywatch-watcher active-window

aw-watcher-window's Introduction

aw-watcher-window

Cross-platform window-Watcher for Linux (X11), macOS, Windows.

Build Status

How to install

To install the pre-built application, go to https://activitywatch.net/downloads/

To build your own packaged application, run make package

To install the latest git version directly from github without cloning, run pip install git+https://github.com/ActivityWatch/aw-watcher-window.git

To install from a cloned version, cd into the directory and run poetry install to install inside an virtualenv. You can run the binary via aw-watcher-window.

If you want to install it system-wide it can be installed with pip install ., but that has the issue that it might not get the exact version of the dependencies due to not reading the poetry.lock file.

Usage

In order for this watcher to be available in the UI, you'll need to have a Away From Computer (afk) watcher running alongside it.

Note to macOS users

To log current window title the terminal needs access to macOS accessibility API. This can be enabled in System Preferences > Security & Privacy > Accessibility, then add the Terminal to this list. If this is not enabled the watcher can only log current application, and not window title.

aw-watcher-window's People

Contributors

basileuserwin avatar chengyuhui avatar cunidev avatar erikbjare avatar exoji2e avatar huantianad avatar iloveitaly avatar johan-bjareholt avatar lgtm-com[bot] avatar modderme123 avatar nikanar avatar valentin-n avatar xylix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aw-watcher-window's Issues

[macos] `loginwindow` reported with latest macOS update

I'm running into an issue where login window is reporting > 1hr of usage over a week period. I think this issue is connected to AFK and how it works.

image

  1. Does Exclude AFK time filter out time where there is no AFK data? i.e. will the login window time above be excluded?
  2. If not, do you think we should just explicitly filter out loginwindow events (string matching on the title)? Or should we improve AFK to 'fill in' the missing time period when the computer was sleeping (similar to what the macOS window watcher implementation does).

Support configuration of aw-server host+port

This binary seems to assume the aw-server is running on localhost:5600.
If aw-server runs on a different machine, it would be convenient to allow configuration of hostname and port of the server.

MacOS: Use realtime accessibility notifications to improve precision and performance

While writing https://github.com/CM-Tech/timeviewer/blob/main/monitor/TimeViewer/AppDelegate.swift, I discovered the swift functions AXObserverCreate and AXObserverAddNotification. This allows the application to extremely efficiently respond to things like title changes while using almost no CPU (in comparison to the 3% that polling uses on my machine). Would it be possible to use something like this in ActivityWatch to prevent polling?

If this is something that you would be interested in, I'd be open to helping take this on

Code makes unclear branches

I got a large bunch of 2017-07-26 03:28:42,691 [WARNING]: Code made an unclear branch (aw_watcher_window.xlib:81) (what does it mean ?), seemingly for all the heartbeats in a 20s period ?

full log
2017-07-26 03:28:42,691 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:42,693 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:42,695 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:43,702 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:43,704 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:43,706 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:44,711 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:44,713 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:44,715 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:45,722 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:45,724 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:45,726 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:46,730 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:46,731 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:46,731 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:48,736 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:48,738 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:48,740 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:49,745 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:49,748 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:49,750 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:50,757 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:50,759 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:50,761 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:51,766 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:51,768 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:51,770 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:52,774 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:52,776 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:52,777 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:53,781 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:53,782 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:53,782 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:54,786 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:54,788 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:54,789 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:55,796 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:55,798 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:55,801 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:56,807 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:56,810 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:56,813 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:57,819 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:57,819 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:57,820 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:58,821 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:58,822 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:58,823 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:59,826 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:59,827 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:28:59,827 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:00,830 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:00,831 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:00,832 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:01,833 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:01,834 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:01,834 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:02,837 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:02,838 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:02,839 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:03,843 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:03,845 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:03,846 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:04,849 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:04,850 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:04,850 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:05,854 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:05,855 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:05,856 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:06,861 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:06,863 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)
2017-07-26 03:29:06,866 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:81)

It was 5 minutes ago and AW didn't crash, but iirc other crashes (in #19) were preceded by this happening.

setup.py on Windows fails on pypiwin32

It tries to get a source distribution (apparently since setuptools doesn't like wheels) and then fails on a build step where it trips over a old-style print statement.

Running pip install pypiwin32 to install it works, since pip successfully picks up the wheel and installs it.

Crashes when wine desktop is active

Tried running aw-qt.exe in Wine, and to my surprise aw-watcher-window crashed when I focused the window!

Don't feel like digging up the cause right now, could be tricky.

Reproduce

  1. Open a wine desktop: $ wine explorer /desktop=shell
  2. Hover

Eh, on second try aw-watcher-window didn't crash... wtf.

[macos] track audible status

I know it's possible, the 'media center' widget knows if audio is playing or not and which application is playing it. I don't know which APIs allow for observing this data though.

Custom title filter

The daily title stats is really useful. But I see something like this

image

So I would like to remove the leading when watching.

I have inspected the source code, wondering whether there is an non-intrusive way to do it.

No titles on MacOS

Not sure if this is a known issue, but the window watcher always reports empty titles for MacOS (Sierra). I'd be happy to help debug, I'd like to get involved with ActivityWatch development.

Permissions issues on MacOS Monterey

I just recently noticed I've had nearly no data logged in AW since upgrading to Monterey, aw-watcher-window's logs are full of

2021-11-20 04:18:06 [ERROR]: Exception thrown while trying to get active window: jxa error: Error: Error: ActivityWatch is not allowed assistive access.  (aw_watcher_window.main:74)

To me, that sounded like AW was missing the Accessibility permissions in System Preferences -> Security & Privacy -> Privacy -> Accessibility, but those permissions are present.

Error logging filling up disk

Today my OS (vanilla Ubuntu 22.04) warned me that I had only a couple of GB left on my main disk. After some dinging I found that aw-watcher-window was spamming my disk with error logs. For example ~/.cache/activitywatch/log/aw-watcher-window is currently 160GB.

In those large log files, I see basically every second an entry like this:

2022-12-05 09:17:59 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "Xlib/protocol/display.py", line 583, in send_and_recv
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 107, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1381, in reply
  File "Xlib/protocol/display.py", line 586, in send_and_recv
Xlib.error.ConnectionClosedError: Display connection closed by server: [Errno 32] Broken pipe

window watcher crashes on Chrome Task Manager window

Opening chrome's task manager (shortcut : Shift-Escape), a pop-up appears stating :

Module aw-watcher-window quit unexpectedly [Restart] [Show details] [Cancel]

Details are

2017-11-21 17:12:57 [INFO ]: Running watcher with poll time 1.0 seconds  (aw_watcher_window.main:35)
2017-11-21 17:12:57 [INFO ]: aw-watcher-window has started  (aw_watcher_window.main:44)
2017-11-21 17:12:57 [INFO ]: Connection to aw-server established  (aw_client.client:281)
2017-11-21 18:10:56 [ERROR]: Exception thrown while trying to get active window: [Errno 5] Input/output error  (aw_watcher_window.main:69)

Pressing "restarting" in the notification popup only makes it crash again (with the same details), for so long as the active window is chrome's task manager. If I restart the watcher with an other window being active, it restarts fine and is stable. And crashes right again as soon as the task manager becomes active again (as my mouse goes over
it, as focus follows mouse in my awesome wm).

xprop details
_NET_WM_STATE(ATOM) = 
_NET_WM_DESKTOP(CARDINAL) = 7
_NET_FRAME_EXTENTS(CARDINAL) = 0, 0, 0, 0
WM_STATE(WM_STATE):
		window state: Normal
		icon window: 0x0
_NET_WM_USER_TIME(CARDINAL) = 2417562315
WM_NORMAL_HINTS(WM_SIZE_HINTS):
		program specified location: 1150, 20
		program specified minimum size: 460 by 270
WM_NAME(UTF8_STRING) = "Task Manager - Google Chrome"
_NET_WM_NAME(UTF8_STRING) = "Task Manager - Google Chrome"
XdndAware(ATOM) = BITMAP
_MOTIF_WM_HINTS(_MOTIF_WM_HINTS) = 0x2, 0x0, 0x1, 0x0, 0x0
_NET_WM_ICON(CARDINAL) = 	Icon (64 x 64):
                        <chrome icon in ascii>	                                                                
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_PID(CARDINAL) = 24459
WM_LOCALE_NAME(STRING) = "en_US.UTF-8"
WM_CLIENT_MACHINE(STRING) = "ker"
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, _NET_WM_PING

900GB Log File caused by error in error handler

I have two log files that are significantly larger than the usual logs, aw-watcher-window_2022-09-26T21-46-19.log which is almost 400MB and aw-watcher-window_2022-10-07T07-36-39.log which is over 900GB!

There appears to be an issue with error handling in aw-watcher-window. Both log files contains an ever-increasing stack trace.
Prior and subsequent logs have an acceptable size between a couple of bytes up to a max of 100KB.

This is with activitywatch version v0.12.0, I haven't updated yet and don't see anything regarding this in the changelogs for v0.12.1.

Head of log file aw-watcher-window_2022-10-07T07-36-39.log:

2022-10-07 07:36:39 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:52)
2022-10-07 07:36:40 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:429)
2022-10-07 15:19:21 [WARNING]: Unable to get window class, got a BadWindow exception.  (aw_watcher_window.xlib:85)
2022-10-07 15:19:21 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:91)
2022-10-07 15:19:21 [WARNING]: Unable to get window query_tree().parent, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:95)
2022-10-07 15:19:21 [WARNING]: Unable to get window property NET_WM_NAME, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:54)
2022-10-07 15:19:21 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 15, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 60, in get_window_name
  File "Xlib/xobject/drawable.py", line 669, in get_wm_name
  File "Xlib/xobject/drawable.py", line 486, in get_full_text_property
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1389, in reply
Xlib.error.BadWindow: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <Resource 0x05600003>, sequence_number = 331, major_opcode = 20, minor_opcode = 0
2022-10-11 15:47:57 [WARNING]: Unable to get window property NET_WM_NAME, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:54)
2022-10-11 15:47:57 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 15, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 60, in get_window_name
  File "Xlib/xobject/drawable.py", line 669, in get_wm_name
  File "Xlib/xobject/drawable.py", line 486, in get_full_text_property
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1389, in reply
Xlib.error.BadWindow: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <Resource 0x05c000d9>, sequence_number = 58876, major_opcode = 20, minor_opcode = 0
2022-10-14 08:53:39 [WARNING]: Unable to get window property NET_WM_NAME, got a BadValue exception from Xlib  (aw_watcher_window.xlib:54)
2022-10-14 08:53:39 [WARNING]: I don't think this case will ever happen, but not sure so leaving this message here just in case.  (aw_watcher_window.xlib:64)
2022-10-14 13:02:28 [WARNING]: Unable to get window class, got a BadWindow exception.  (aw_watcher_window.xlib:85)
2022-10-14 13:02:28 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:91)
2022-10-14 13:02:28 [WARNING]: Unable to get window query_tree().parent, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:95)
2022-10-14 13:02:28 [WARNING]: Unable to get window property NET_WM_NAME, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:54)
2022-10-14 13:02:28 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 15, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 60, in get_window_name
  File "Xlib/xobject/drawable.py", line 669, in get_wm_name
  File "Xlib/xobject/drawable.py", line 486, in get_full_text_property
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1389, in reply
Xlib.error.BadWindow: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <Resource 0x06200003>, sequence_number = 3736, major_opcode = 20, minor_opcode = 0
2022-10-15 08:15:21 [WARNING]: Unable to get window class, got a BadWindow exception.  (aw_watcher_window.xlib:85)
2022-10-15 08:15:21 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:91)
2022-10-15 08:15:21 [WARNING]: Unable to get window query_tree().parent, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:95)
2022-10-15 08:15:21 [WARNING]: Unable to get window property NET_WM_NAME, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:54)
2022-10-15 08:15:21 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 15, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 60, in get_window_name
  File "Xlib/xobject/drawable.py", line 669, in get_wm_name
  File "Xlib/xobject/drawable.py", line 486, in get_full_text_property
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1389, in reply
Xlib.error.BadWindow: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <Resource 0x02200004>, sequence_number = 35501, major_opcode = 20, minor_opcode = 0
2022-10-15 15:40:06 [WARNING]: Unable to get window class, got a BadWindow exception.  (aw_watcher_window.xlib:85)
2022-10-15 15:40:06 [WARNING]: Code made an unclear branch  (aw_watcher_window.xlib:91)
2022-10-15 15:40:06 [WARNING]: Unable to get window query_tree().parent, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:95)
2022-10-15 15:40:06 [WARNING]: Unable to get window property NET_WM_NAME, got a BadWindow exception from Xlib  (aw_watcher_window.xlib:54)
2022-10-15 15:40:07 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 15, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 60, in get_window_name
  File "Xlib/xobject/drawable.py", line 669, in get_wm_name
  File "Xlib/xobject/drawable.py", line 486, in get_full_text_property
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1389, in reply
Xlib.error.BadWindow: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <Resource 0x07a00004>, sequence_number = 4872, major_opcode = 20, minor_opcode = 0
2022-10-15 15:43:16 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "Xlib/protocol/display.py", line 583, in send_and_recv
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1381, in reply
  File "Xlib/protocol/display.py", line 586, in send_and_recv
Xlib.error.ConnectionClosedError: Display connection closed by server: [Errno 32] Broken pipe
2022-10-15 15:43:17 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "Xlib/protocol/display.py", line 583, in send_and_recv
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1381, in reply
  File "Xlib/protocol/display.py", line 586, in send_and_recv
Xlib.error.ConnectionClosedError: Display connection closed by server: [Errno 32] Broken pipe
2022-10-15 15:43:18 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "Xlib/protocol/display.py", line 583, in send_and_recv
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1367, in __init__
  File "Xlib/protocol/display.py", line 355, in send_request
  File "aw_watcher_window/main.py", line 74, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 53, in get_current_window
  File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 37, in get_current_window
  File "aw_watcher_window/xlib.py", line 20, in _get_current_window_id
  File "Xlib/xobject/drawable.py", line 472, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1369, in __init__
  File "Xlib/protocol/rq.py", line 1381, in reply
  File "Xlib/protocol/display.py", line 586, in send_and_recv
Xlib.error.ConnectionClosedError: Display connection closed by server: [Errno 32] Broken pipe
2022-10-15 15:43:19 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:77)
Traceback (most recent call last):
  File "Xlib/protocol/display.py", line 583, in send_and_recv
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Got BadWindow exception while trying to get active window on Linux

Got this while running aw-watcher-window (commit 7612c4a):

2017-06-28 12:36:49,972 [INFO ]: Running watcher with poll time 1.0 seconds  (aw_watcher_window.main:35)            
2017-06-28 12:36:49,973 [INFO ]: aw-watcher-window has started  (aw_watcher_window.main:43)                         
2017-06-28 12:36:50,019 [INFO ]: Connection to aw-server established  (aw_client.client:251)                        
2017-06-28 12:36:50,030 [INFO ]: Loaded 1 failed requests from queuefile  (aw_client.client:236)                    
2017-06-28 20:43:26,199 [WARNING]: Unable to get window class, got a BadWindow exception.  (root:74)                

2017-06-28 20:43:26,199 [WARNING]: Code made an unclear branch  (root:79)                                           
2017-06-28 20:43:26,202 [ERROR]: Exception thrown while trying to get active window: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <class 'Xlib.xobject.resource.Resource'>(0x00c00004), sequence_number = 43768, major_opcode = 15, minor_opcode = 0  (aw_watcher_window.main:64)
Traceback (most recent call last):                        
  File "/home/erb/Programming/activitywatch/aw-watcher-window/aw_watcher_window/main.py", line 61, in heartbeat_loop
    current_window = get_current_window()                 
  File "/home/erb/Programming/activitywatch/aw-watcher-window/aw_watcher_window/lib.py", line 44, in get_current_window
    return get_current_window_linux()                     
  File "/home/erb/Programming/activitywatch/aw-watcher-window/aw_watcher_window/lib.py", line 13, in get_current_window_linux
    cls = xlib.get_window_class(window)                   
  File "/home/erb/Programming/activitywatch/aw-watcher-window/aw_watcher_window/xlib.py", line 80, in get_window_class
    window = window.query_tree().parent                   
  File "/home/erb/Programming/activitywatch/venv_main2/lib/python3.6/site-packages/python_xlib-0.19-py3.6.egg/Xlib/xobject/drawable.py", line 425, in query_tree
  File "/home/erb/Programming/activitywatch/venv_main2/lib/python3.6/site-packages/python_xlib-0.19-py3.6.egg/Xlib/protocol/rq.py", line 1360, in __init__
  File "/home/erb/Programming/activitywatch/venv_main2/lib/python3.6/site-packages/python_xlib-0.19-py3.6.egg/Xlib/protocol/rq.py", line 1380, in reply
Xlib.error.BadWindow: <class 'Xlib.error.BadWindow'>: code = 3, resource_id = <class 'Xlib.xobject.resource.Resource'>(0x00c00004), sequence_number = 43768, major_opcode = 15, minor_opcode = 0

During handling of the above exception, another exception occurred:                                                 

Traceback (most recent call last):                        
  File "/usr/lib64/python3.6/runpy.py", line 193, in _run_module_as_main                                            
    "__main__", mod_spec)    
  File "/usr/lib64/python3.6/runpy.py", line 85, in _run_code                                                       
    exec(code, run_globals)  
  File "aw_watcher_window/__main__.py", line 3, in <module>                                                         
    main()                   
  File "/home/erb/Programming/activitywatch/aw-watcher-window/aw_watcher_window/main.py", line 45, in main          
    heartbeat_loop(client, bucket_id, poll_time=args.poll_time, exclude_title=args.exclude_title)                   
  File "/home/erb/Programming/activitywatch/aw-watcher-window/aw_watcher_window/main.py", line 65, in heartbeat_loop
    traceback.print_exc(e)   
  File "/usr/lib64/python3.6/traceback.py", line 159, in print_exc                                                  
    print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)                                           
  File "/usr/lib64/python3.6/traceback.py", line 100, in print_exception                                            
    type(value), value, tb, limit=limit).format(chain=chain):                                                       
  File "/usr/lib64/python3.6/traceback.py", line 497, in __init__                                                   
    capture_locals=capture_locals)                        
  File "/usr/lib64/python3.6/traceback.py", line 332, in extract                                                    
    if limit >= 0:           
TypeError: '>=' not supported between instances of 'BadWindow' and 'int'                                            

Being in the Desktop of Windows reports title as empty

Basically the title. I noticed these Events popping up in my uncategorized and think this is the windows desktop.
grafik

So I tried being on the desktop for 30s and looked at the raw buckets. It only showed explorer.exe without a title for the time on Desktop.
grafik

Is this a bug, intended or can this be fixed? Maybe a Special Case to add something to the title? I would just like to filter it out and add it to my Misc Category, so it doesn't always show such a high time of Uncategorized Activity

Aw watcher window quits without any logged error on MacOS Catalina

I'm on a rather old MacOS:

  System Version:	macOS 10.15.7 (19H2)
  Kernel Version:	Darwin 19.6.0
  Boot Volume:	Macintosh HD
  Boot Mode:	Normal
  Secure Virtual Memory:	Enabled
  System Integrity Protection:	Enabled

Just installed ActivityWatch, v0.12.1, it had a small hiccup when starting the first time, had to start it a second time, then the tray icon appeared, but also a message about aw-watcher-window having quit unexpectedly:

image

Clicking "restart" closes the window, but the module just quit again without giving the error window.

In the log there is nothing significant:

2022-10-31 13:13:57 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
2022-10-31 13:13:58 [INFO ]: Using swift strategy, calling out to swift binary  (aw_watcher_window.main:67)
2022-10-31 13:13:58 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:429)

UnicodeDecodeError in xlib.py

Some internet page title caught the aw-window-watcher by surprise :

2017-07-20 16:20:19,793 [INFO ]: No longer AFK  (aw_watcher_afk.afk:99)
2017-07-20 16:30:45,707 [INFO ]: Became AFK  (aw_watcher_afk.afk:105)
2017-07-20 16:31:05,738 [INFO ]: No longer AFK  (aw_watcher_afk.afk:99)
2017-07-20 17:51:01,673 [ERROR]: Exception thrown while trying to get active window: 'bytes' object has no attribute 'encode'  (aw_watcher_window.main:73)
Traceback (most recent call last):
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/xlib.py", line 62, in get_window_name
    return d.value.decode('utf8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 40: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/main.py", line 70, in heartbeat_loop
    current_window = get_current_window()
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/lib.py", line 44, in get_current_window
    return get_current_window_linux()
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/lib.py", line 14, in get_current_window_linux
    name = xlib.get_window_name(window)
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/xlib.py", line 64, in get_window_name
    return d.value.encode('utf8').decode('utf8')
AttributeError: 'bytes' object has no attribute 'encode'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/aw-watcher-window", line 11, in <module>
    load_entry_point('aw-watcher-window==0.2', 'console_scripts', 'aw-watcher-window')()
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/main.py", line 45, in main
    heartbeat_loop(client, bucket_id, poll_time=args.poll_time, exclude_title=args.exclude_title)
  File "/home/will/.local/lib/python3.6/site-packages/aw_watcher_window/main.py", line 74, in heartbeat_loop
    traceback.print_exc(e)
  File "/usr/lib/python3.6/traceback.py", line 159, in print_exc
    print_exception(*sys.exc_info(), limit=limit, file=file, chain=chain)
  File "/usr/lib/python3.6/traceback.py", line 100, in print_exception
    type(value), value, tb, limit=limit).format(chain=chain):
  File "/usr/lib/python3.6/traceback.py", line 486, in __init__
    _seen=_seen)
  File "/usr/lib/python3.6/traceback.py", line 497, in __init__
    capture_locals=capture_locals)
  File "/usr/lib/python3.6/traceback.py", line 332, in extract
    if limit >= 0:
TypeError: '>=' not supported between instances of 'AttributeError' and 'int'
Reading active process stderr...
Traceback (most recent call last):
  File "/home/will/.local/lib/python3.6/site-packages/aw_qt-0.1-py3.6.egg/aw_qt/trayicon.py", line 110, in rebuild_modules_menu
    show_module_failed_dialog(module)
  File "/home/will/.local/lib/python3.6/site-packages/aw_qt-0.1-py3.6.egg/aw_qt/trayicon.py", line 96, in show_module_failed_dialog
    box.setDetailedText(module.stderr())
  File "/home/will/.local/lib/python3.6/site-packages/aw_qt-0.1-py3.6.egg/aw_qt/manager.py", line 108, in stderr
    self._log += self._process.stderr.read()
AttributeError: 'NoneType' object has no attribute 'read'
Aborted (core dumped)

Not sure how I got it, couldn't reproduce by browsing around the same pages with possible strange characters in window title, and then some.

maybe line 63 of xlib.py, which currently reads except UnicodeError:, should be except UnicodeError, UnicodeDecodeError:, since it seems to be a catch-all-and-coerce type code block anyway. But I dunno.

Needed: absolute file path in data model

I'm pulling out custom reports and I need the absolute path, not just the filename. From that you can get the real formatted/friendly app name, icon, and more. Hopefully it's not too awkward to get

fetching titles on macOS

#29 is replacing the logic for retrieving windowtitle and active app from macOS clients.

There seems to be lots of options on how to do this, and we should definitely replace the applescript.

I just want to share a bit of what I found out.

The nicest way for us to do this is probably through python and AppKit.

I can easily get the active application by:

from AppKit import NSWorkspace
workspace = NSWorkspace.sharedWorkspace()
app_name = workspace.frontmostApplication().localizedName()

This gist tries to do what we want.

However, it does not work all the time for me, since window['kCGWindowOwnerName'] == 'iTerm', while app.localizedName() == 'iTerm2'. Also, it seems that the gist is just returning the first match. Maybe windowList is always sorted in the correct order, not sure.

[Windows] Exception thrown while trying to get active window

Reported by @Creve on Discord.


Logs:

2023-04-16 18:56:19 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:124)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 106, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 65, in get_current_window
  File "aw_watcher_window\lib.py", line 42, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "aw_watcher_window\windows.py", line 15, in get_app_path
pywintypes.error: (87, 'OpenProcess', 'Параметр задан неверно.')

  • OS: Windows
  • ActivityWatch: ActivityWatch v0.12.3b1

[macOS] watcher unable to get name of current app if it has no dock icon

I just noticed that aw-watcher-window seems to be unable to get the current app name if the app has no icon in the dock. Specifically I noticed with this app which has the option to keep running while hiding the dock icon. With the icon hidden aw-watcher-window does not identify that the app is being used and only records a generic "Google Chrome" event (I believe it's made using react-native-web, which itself uses Electron?) .

Screen Shot 2020-04-16 at 3 51 08 PM

[macos] detect incognito on safari

from this comment

Note that safari is active, so we can actually use our accessibility privileges to inspect the menu bar for incognito silently like the above link suggests. Additionally, the title should contain , Private Browsing so we could just filter that

[macOS] Exception thrown while trying to get active window: error compiling jxa script

On a fresh installation of ActivityWatch on Mac, the aw-watcher-window application failed to work, resulting in all applications reporting as "unknown".

image

Inspecting the logs, this was the error message, logged approximately every second:

[ERROR]: Exception thrown while trying to get active window: error compiling jxa script  (aw_watcher_window.main:74)

When I pasted printAppStatus.jxa into the script editor to debug, the error message reported

Error on line 1: SyntaxError: Invalid character: '#'

Opening the package contents and deleting line 1 from printAppStatus.jxa then solved the problem for me.

I didn't see this error come up in any google searches or existing issues, which was odd to me because the first thing I tried was to remove and reinstall the app a couple times but this bug was consistent on a fresh install on my machine (running Mojave 10.14.6). It's a simple code fix, as seen above, but not seeing the bug reported elsewhere, I wasn't sure if it was affecting anybody else's machine. It seems like it should have, given that the bug was a syntax error in the jxa file.

Is it possible to replace aw-watcher-window?

I use GNOME Wayland, and aw-watcher-window doesnt work on that, so I'm creating a simple GNOME extension that would get the active window title via GNOME's API, like in #46. The aw-client-js library can't be easily used in GJS, so the actual watcher will be made in Python and communitcate with the extension via D-Bus.

However, the question is, is it possible for users to replace aw-watcher-window? What I mean is some sort of a config to prevent aw-watcher-window from starting automatically and starting a custom version (eg. aw-watcher-window-gnome) instead.

[Linux] 'BadRRModeError' object has no attribute 'sequence_number'

aw-watcher-window randomly encounters this error, which then causes it to hang with high CPU usage. This is probably related to python-xlib/python-xlib#241
Please let me know what other information I should provide

Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 106, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 59, in get_current_window
  File "aw_watcher_window/lib.py", line 17, in get_current_window_linux
  File "aw_watcher_window/xlib.py", line 67, in get_window_name
  File "Xlib/xobject/drawable.py", line 476, in get_full_property
  File "Xlib/xobject/drawable.py", line 455, in get_property
  File "Xlib/protocol/rq.py", line 1368, in __init__
  File "Xlib/protocol/rq.py", line 1380, in reply
  File "Xlib/protocol/display.py", line 612, in send_and_recv
  File "Xlib/protocol/display.py", line 719, in parse_response
  File "Xlib/protocol/display.py", line 745, in parse_error_response
AttributeError: 'BadRRModeError' object has no attribute 'sequence_number'```

[macos] Process crashed without error

Watcher process suddenly died after running okay for weeks (last commit, from terminal). Lost 2h of data.

Last messages:

2024-02-14 11:50:18 [aw-watcher-window-macos] [DEBUG] [heartbeat] bucket: aw-watcher-window_erb-m2.localdomain, timestamp: 2024-02-14 10:50:18 +0000, pulsetime: 1.7, app: Alacritty, title: [0:mono-gpt-engineer] ~/P/m/app (/Users/erb/Programming/mono-gpt-engineer/app), url:
2024-02-14 11:50:18 [aw-watcher-window-macos] [DEBUG] sending old heartbeat for merging
2024-02-14 11:50:23 [DEBUG]: queue path '/Users/erb/Library/Application Support/activitywatch/aw-client/queued/aw-watcher-window.v1.persistqueue'  (aw_client.client:418)
⏎

Exit code 0.

Mac: high CPU in trustd/syspolicd/virus scanner when enabled

I've installed activitywatch on my up to date catalina Mac by downloading the the activitywatch-v0.9.2-macos-x86_64.dmg file, dragging the icon to application and then went to /Application, clicked right->open, answered the security question and got an icon in my tray/menu bar. I also went and added activitywatch to the accessibility security&privacy list.

Unfortunately, now my system has about 60% of an CPU running trustd, syspolicyd and my virus scanner, which is enough to start the fans.

I can trigger this by quitting activitywatch via the menu icon (all processes stop using CPU) and restarting it (all start up again). When I play with the started modules, the CPU load stops when I stop aw-watcher-window and starts again when I enable it. The rest (server and afk) make no problems. When I disable the virus scanner, the load of the virus scanner goes away but trustd/systpolicyd stay on.

The App was installed a few days ago and I noticed the high CPU (by the starting fan) for a few days. This might correlate with a mac os x update? At least I remember a nightly restart at the same time I started noticing the fans.

(started as a comment in ActivityWatch/activitywatch#334 (comment))

[Windows] aw watcher window does not track correctly

This is my log message:

2022-12-11 18:40:20 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
2022-12-11 18:40:21 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:429)
2022-12-11 18:56:47 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 18:56:48 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 18:58:53 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 18:58:54 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 18:58:55 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 19:05:01 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 19:10:51 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)
2022-12-11 19:12:39 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:110)
Traceback (most recent call last):
  File "aw_watcher_window\main.py", line 107, in heartbeat_loop
  File "aw_watcher_window\lib.py", line 57, in get_current_window
  File "aw_watcher_window\lib.py", line 40, in get_current_window_windows
  File "aw_watcher_window\windows.py", line 26, in get_app_name
  File "wmi.py", line 1072, in query
  File "wmi.py", line 1072, in <listcomp>
  File "win32com\client\dynamic.py", line 324, in __getitem__
  File "win32com\client\util.py", line 41, in __getitem__
  File "win32com\client\util.py", line 62, in __GetIndex
pywintypes.com_error: (-2147217385, 'OLE error 0x80041017', None, None)

[macos] Process crashes with Unexpectedly found nil while unwrapping an Optional value

I see the aw-watcher-window process randomly crashing on MacOS after a while. I cannot quite determine what triggers the crash.

Here is the output of the process with --verbose:

$ /Applications/ActivityWatch.app/Contents/MacOS/aw-watcher-window --verbose
2024-02-13 14:00:53 [DEBUG]: SingleInstance lockfile: /Users/dmesch/Library/Caches/activitywatch/client_locks/aw-watcher-window-at-127.0.0.1-on-5600  (aw_client.singleinstance:22)
2024-02-13 14:00:53 [DEBUG]: queue path '/Users/dmesch/Library/Application Support/activitywatch/aw-client/queued/aw-watcher-window.v1.persistqueue'  (aw_client.client:407)
2024-02-13 14:00:53 [INFO ]: aw-watcher-window started  (aw_watcher_window.main:62)
usage: aw-watcher-window [-h] [--host HOST] [--port PORT] [--testing] [--exclude-title] [--verbose] [--poll-time POLL_TIME] [--strategy {jxa,applescript,swift}]
aw-watcher-window: error: unrecognized arguments: -B -S -E -s -c from multiprocessing.resource_tracker import main;main(6)
usage: aw-watcher-window [-h] [--host HOST] [--port PORT] [--testing] [--exclude-title] [--verbose] [--poll-time POLL_TIME] [--strategy {jxa,applescript,swift}]
aw-watcher-window: error: unrecognized arguments: --multiprocessing-fork tracker_fd=7 pipe_handle=9
2024-02-13 14:00:54 [INFO ]: Using swift strategy, calling out to swift binary  (aw_watcher_window.main:67)
2024-02-13 14:00:54 [DEBUG]: Starting new HTTP connection (1): 127.0.0.1:5600  (urllib3.connectionpool:228)
2024-02-13 14:00:54 [DEBUG]: http://127.0.0.1:5600 "POST /api/0/buckets/aw-watcher-window_98dd605457bd.ant.amazon.com HTTP/1.1" 304 0  (urllib3.connectionpool:456)
2024-02-13 14:00:54 [INFO ]: Connection to aw-server established by aw-watcher-window  (aw_client.client:436)
2024-02-13 14:01:15 [aw-watcher-window-macos] [INFO] Failed to create bucket
main/macos.swift:282: Fatal error: Unexpectedly found nil while unwrapping an Optional value
2024-02-13 16:59:45 [DEBUG]: queue path '/Users/dmesch/Library/Application Support/activitywatch/aw-client/queued/aw-watcher-window.v1.persistqueue'  (aw_client.client:407)

Note the exception main/macos.swift:282: Fatal error: Unexpectedly found nil while unwrapping an Optional value.

Looking at the code location, I am not on the same version as the master branch. I am using the version bundled with ActivityWatch version v0.12.2.

This line could be a candidate:
https://github.com/ActivityWatch/aw-watcher-window/blob/f08afe80cc3af1c62f948abb015be0ad3adcec67/aw_watcher_window/macos.swift#L282C1-L282C55

In that case the issue would be fixed with 82d9673

Does the .dmg package on https://activitywatch.net/ potentially contain an old version?

[macos] url changes are not detected

If you switch tabs, that is reported, but navigating within a tab/window is not noticed using the existing logic. This can cause the watcher to report longer time on a particular url/title than we should.

Error shows after running for a day constantly

This error shows up when leaving the computer inactive overnight – might be useful to note:

IndexError: list index out of range
/Users/igatnas/Projects/activitywatch/venv/lib/python3.6/site-packages/aw_watcher_window/printAppTitle.scpt: execution error: git: 'pull && hub checkout develop && hub pull (git)"' is not a git command. See 'git --help'. (1)
2017-09-07 09:57:36 [ERROR]: Exception thrown while trying to get active window: list index out of range  (aw_watcher_window.main:69)
Traceback (most recent call last):
  File "/Users/igatnas/Projects/activitywatch/venv/lib/python3.6/site-packages/aw_watcher_window/main.py", line 66, in heartbeat_loop
    current_window = get_current_window()
  File "/Users/igatnas/Projects/activitywatch/venv/lib/python3.6/site-packages/aw_watcher_window/lib.py", line 46, in get_current_window
    return get_current_window_macos()
  File "/Users/igatnas/Projects/activitywatch/venv/lib/python3.6/site-packages/aw_watcher_window/lib.py", line 23, in get_current_window_macos
    title = macos.getTitle(info)
  File "/Users/igatnas/Projects/activitywatch/venv/lib/python3.6/site-packages/aw_watcher_window/macos.py", line 17, in getTitle
    return info.split('","')[1][:-1]
IndexError: list index out of range

Track webcam and microphone usage

https://github.com/antonfisher/go-media-devices-state

I think webcam and microphone could be two interesting additions to the heartbeat payload here. The idea would be:

If AFK is true but webcam and/or microphone are on, still treat this time as active. In other words, still track long-running video conferences as active time on the computer.

What do you think? Is this watcher the right place for it?

exclude_title does not seem to be respected on Windows 10

My aw-watcher-window.ini is as follows but still window titles are sent to the server.
I tried both aw-qt.exe and aw-watcher-window.exe but I got the same result.

[aw-watcher-window]
poll_time = 10.0
exclude_title = yes

[aw-watcher-window-testing]
poll_time = 1.0
exclude_title = yes

ActivityWatch Version: v0.8.0b9
OS: Windows 10 Pro
Config path: C:\Users\user\AppData\Local\activitywatch\activitywatch\aw-watcher-window\aw-watcher-window.ini

[Windows] Switch to use title instead of executable

It seems the watcher is using the executable name to display and I don't really understand where it takes the color.
It would be nice if the graph would use the window title - or at least color it according to the settings for the window title (consistent to the coloring in the activity tab)

[Windows] Apps run in Administrator not got recorded

I saw some vacancy on the timeline.
image

After some tests I realized they are apps run as administrator (e.g. Windows Terminal (Admin), Process Hacker (Administrator) ), which don't have any logs in the Raw Data.

I tried 12.2 and 12.3b15, both the same.

I tried to set Run As Administrator in the properties of aw-watcher-window.exe, but it just fail to start by aw-qt

Window Watcher Not Working on M1 Monterey

No Application or windows have been logged post installation.

Activity Watcher Version: v0.12.0b2

Python Information:

  Version:	3.8.2
  Obtained from:	Apple
  Last Modified:	30/04/21, 9:54 PM
  Kind:	Universal

System Information:

Model Name:	MacBook Air
Model Identifier:	MacBookAir10,1
Chip:	                Apple M1
Total Number of Cores:	8 (4 performance and 4 efficiency)
Memory:	8 GB
System Version:	macOS 12.4 (21F79)
Kernel Version:	Darwin 21.5.0

Log:

2022-05-31 22:19:46 [ERROR]: Exception thrown while trying to get active window  (aw_watcher_window.main:75)
Traceback (most recent call last):
  File "aw_watcher_window/main.py", line 72, in heartbeat_loop
  File "aw_watcher_window/lib.py", line 55, in get_current_window
  File "aw_watcher_window/lib.py", line 27, in get_current_window_macos
  File "aw_watcher_window/macos_jxa.py", line 64, in getInfo
Exception: jxa error: Error: Error: An error occurred.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.