activitywatch
activitywatch copied to clipboard
error compiling jxa script
-
[x] I am on the latest ActivityWatch version.
-
[x] I have searched the issues of this repo and believe that this is not a duplicate.
-
OS Name and Version: MacOS Mojave 10.14.6
-
ActivityWatch version: v0.11.0
Describe the bug
aw-window-watcher cannot see the name of any windows (congrats on the new release, everything works perfectly on windows!)
To Reproduce
1. Download the latest release
2. Start activitywatch
Expected behavior
title of foreground window or app should be seen
Documentation

Here's an excerpt from the aw-window-watcher logs. All other logs look fine and the server is getting a heartbeat
2021-06-17 21:02:28 [INFO ]: aw-watcher-window started (aw_watcher_window.main:51)
2021-06-17 21:02:29 [INFO ]: Connection to aw-server established by aw-watcher-window (aw_client.client:417)
2021-06-17 21:02:29 [ERROR]: Exception thrown while trying to get active window: error compiling jxa script (aw_watcher_window.main:74)
Is it not working at all, or just showing empty/unknown titles?
Did you re-give it accessibility permissions? I briefly documented it here: https://docs.activitywatch.net/en/latest/updating.html
You can also work around this by switching to the old method used by aw-watcher-window, as described here: https://forum.activitywatch.net/t/how-to-update-to-v11/1274/3?u=erikbjare
Thanks for the response!
- Right now the window-watcher is just showing empty/unknown titles. The Chrome watcher works as expected though.
- Was also was getting the
Cannot read property 'label' of undefined
error mentioned in that thread but resetting the categories fixed it.
- Was also was getting the
- I re-gave accessibility permissions to activity watch (though there was no popup like in the previous version
- What are the downsides to using the old aw-watcher-window method?
Hmm adding strategy_macos = "applescript"
to the aw-watcher-window toml and restarting activitywatch doesn't seem to change anything
@8bitgentleman That's weird... If you put some invalid value in the config, does it at least crash due to invalid config? (trying to make sure that the config is respected)
You can also try passing --strategy applescript
as a CLI parameter.
though there was no popup like in the previous version
Hmm, it should still appear. Are you sure it just didn't get buried under other windows? (it doesn't steal focus)
What are the downsides to using the old aw-watcher-window method?
The new method has some extra features (logs url, audible, incognito for some browsers which expose the info through the accessibility API, without needing a browser watcher).
But the old one should work just as before, with the added benefit of now running in-process instead of starting a new one on every poll (better performance) and not suffering from the severe vulnerability that existed in v0.10.0.
- Invalid values in the config do cause a crash so that's good but
strategy_macos = "applescript"
seems to be ignored (still the same jxa error in the logs) - How should I pass the CLI parameter? Should I run something like
./aw-qt --strategy applescript
? - Tried running with no other windows open and previous accessibility permissions removed. After install, on first launch activitywatch crashes silently then on second run and all moving forward it launches fine. Would console logs be helpful?
- How should I pass the CLI parameter? Should I run something like
./aw-qt --strategy applescript
?
Try ./aw-watcher-window --strategy applescript
, but first disable aw-watcher-window in the tray icon menu.
- Tried running with no other windows open and previous accessibility permissions removed. After install, on first launch activitywatch crashes silently then on second run and all moving forward it launches fine. Would console logs be helpful?
Hmm, I've noticed this 'second time it works fine' myself. Assumed it had something to do with gatekeeper/security checks, but not sure.
If you see anything helpful in the logs, that'd be great!
Having same issue on same system:
OS Name and Version: MacOS Mojave 10.14.6 ActivityWatch version: v0.11.0
I've just installed an app an hour ago so everything is in default.
Terminal and ActivityWatch added to Preferences - Security & Privacy - Accessibility
Any other permissions required? I have noticed that I can't add anything to Automation. Is it needed? (So I don't have rights on my Mac)
I'm using AMP for Endpoints (if talking about security software installed on OS) https://www.cisco.com/c/en/us/products/collateral/security/fireamp-endpoints/datasheet-c78-733181.html
Any hint on what could be missing?
I've collected all errors (maybe related with compiling jxa script
error):
Log file: 2021-07-26 12:21:03 [ERROR]: Exception thrown while trying to get active window: error compiling jxa script (aw_watcher_window.main:74)
Browser: TypeError: Cannot read property 'timestamp' of null. See dev console (F12) and/or server logs for more info. TypeError: Cannot read property 'map' of undefined. See dev console (F12) and/or server logs for more info.
vue.runtime.esm.js:1888 TypeError: Cannot read property 'timestamp' of null
at aw-client.js:118
at Array.forEach (
vue.runtime.esm.js:1888 TypeError: Cannot read property 'map' of undefined
at o.
Downgrade to 0.10.0 helped to solve this issue, but OS throws this periodically:
“ActivityWatch“ wants access to control “System Events“. Allowing control will provide access to documents and data in “System Events“, and to perform actions within that app.
This gave me an idea to give System Events permission to Accessibility (if this permission is needed), but for some reason it asks again an again.
In Automation section I already have ActivityWatch -> System Events checked.
This may have been fixed by https://github.com/ActivityWatch/aw-watcher-window/pull/59.
Possibly related: on macOS Monterey (12.1) and I was getting this over and over in the aw-watcher-window log:
[ERROR]: Exception thrown while trying to get active window: jxa error: Error: Error: An error occurred. (aw_watcher_window.main:74)
So I ran aw-watcher-window from the terminal:
$ aw-watcher-window
2022-01-06 12:02:40 [INFO ]: aw-watcher-window started (aw_watcher_window.main:51)
Process Process-1:
Traceback (most recent call last):
File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/Cellar/[email protected]/3.9.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.9/site-packages/aw_watcher_window/macos_permissions.py", line 15, in ensure_permissions
from ApplicationServices import AXIsProcessTrusted
File "/usr/local/lib/python3.9/site-packages/ApplicationServices/__init__.py", line 9, in <module>
import CoreText
File "/usr/local/lib/python3.9/site-packages/CoreText/__init__.py", line 31, in <module>
import CoreText._manual as m # isort:skip # noqa: E402
RuntimeError: Wrong version of PyObjC C API (got 22, expected 21)
2022-01-06 12:02:41 [INFO ]: Connection to aw-server established by aw-watcher-window (aw_client.client:410)
^C2022-01-06 12:03:07 [ERROR]: Unhandled exception (root:43)
Traceback (most recent call last):
File "/usr/local/bin/aw-watcher-window", line 8, in <module>
sys.exit(main())
File "/usr/local/lib/python3.9/site-packages/aw_watcher_window/main.py", line 55, in main
heartbeat_loop(
File "/usr/local/lib/python3.9/site-packages/aw_watcher_window/main.py", line 96, in heartbeat_loop
sleep(poll_time)
KeyboardInterrupt
The RuntimeError: Wrong version of PyObjC C API (got 22, expected 21)
suggested that running pip install pyobjc
might help, and it seems to have resolved the issue for me. I'm unsure what else will break by having a different pyobjc version though. YMMV. Hope this helps!
Hey all, does anyone have a solution other than downgrading to 0.10.0 (This works for me)? I have an apple silicon MacBook Pro and also encountered the same errors. @thecadams are you suggesting that I install pyobjc using pip from Python that is preinstalled on macos? I have installed it using homebrew.
@jasonminsookim I found what I believe to be a reliable solution, although it does require a little bit of command line usage (but no third party apps or permissions). Let me know if this works for you. While it's tempting, users should not revert to 0.10 because of security issues on MacOS that were fixed in 0.11.
@may i have the same issue and tried your method but it did not work for me
@NafeeJ Did you ensure that Terminal AND ActivityWatch have Accessiblity permissions? And that Terminal has system events permissions?
@may yes i have
Went back to v10 to make it work (which doesn't use jxa).
The jxa script compiles for me, but executing it returns an error.
Tried running printAppStatus.jxa
in Script Editor and it worked after I gave it Accessibility permissions. But giving ActivityWatch/Terminal permissions didn't work for me.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.