activitywatch: Fails to get active window on macOS
Mac OSX 10.12.6 Sierra, running all modules + aw-watcher-spotify + aw-watcher-web
Python 3.6.3 :: Anaconda, Inc.
I added the last heartbeat for debugging purposes
Inserted:{'id': 1148, 'timestamp': datetime.datetime(2018, 9, 11, 6, 15, 45, 412000, tzinfo=datetime.timezone.utc), 'duration': datetime.timedelta(0), 'data': {'url': 'https://chrome.google.com/webstore/detail/chrome-better-history/aadbaagbanfijdnflkhepgjmhlpppbad', 'title': 'Chrome Better History - Chrome Web Store', 'audible': False, 'incognito': False}} (aw_datastore.datastore.Bucket:120)
/Documents/activitywatch/aw_watcher_window/printAppTitle.scpt: execution error: System Events got an error: Can’t get application process 1 whose frontmost = true. Invalid index. (-1719)
2018-09-11 14:26:19 [ERROR]: Exception thrown while trying to get active window: list index out of range (aw_watcher_window.main:68)
Traceback (most recent call last):
File "aw_watcher_window/main.py", line 65, in heartbeat_loop
File "aw_watcher_window/lib.py", line 46, in get_current_window
File "aw_watcher_window/lib.py", line 23, in get_current_window_macos
File "aw_watcher_window/macos.py", line 17, in getTitle
IndexError: list index out of range
/Users/virenmohindra/Documents/activitywatch/aw_watcher_window/printAppTitle.scpt: execution error: System Events got an error: Can’t get application process 1 whose frontmost = true. Invalid index. (-1719)
2018-09-11 15:10:08 [ERROR]: Exception thrown while trying to get active window: list index out of range (aw_watcher_window.main:68)
and then the same error keeps on getting repeated –
../Documents/activitywatch/aw_watcher_window/printAppTitle.scpt: execution error: sh: -c: lish: -c: line 1: syntax error: unexpected end of file (2)
2018-09-11 22:49:23 [ERROR]: Exception thrown while trying to get active window: list index out of range (aw_watcher_window.main:68)
Please let me know if you need the log files
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 1
- Comments: 22 (8 by maintainers)
Hello all. I experienced this as well, it’s not fatal, but it came up when running in the terminal. The context was that Firefox crashed while I was away from the computer and for a while, there might not have actually been an active window? The status messages went back to normal after focusing on other windows. Unfortunately, I have not been able to reproduce the issue despite trying to get into situations with no active window.
It seems like https://github.com/ActivityWatch/aw-watcher-window/blob/cea4bf048ed9e4af66445bff5015e38c510ec892/aw_watcher_window/macos.py assumes that there will always be an active window.
In the AW gui, the watcher_window shows “unknown” for this time period. That seems reasonable as-is, so perhaps the “solution” here is silence the error?
@Patrick3131 Yes that’s why it’s failing. To test the command either move back activitywatch to the Downloads folder or enter the new path to the printAppTitle.scpt in the command.