ActivityWatch / activitywatch

The best free and open-source automated time tracker. Cross-platform, extensible, privacy-focused.
https://activitywatch.net/
Mozilla Public License 2.0
12.65k stars 565 forks source link

Installation failed on Ubuntu 24: server is loading but no activity is being monitored. #1103

Closed FelixRoy closed 1 month ago

FelixRoy commented 1 month ago

Hi there! Thanks for developping ActivityWatch, I hope I will be able to use it :)

Describe the bug

After installing following the installation guide, the server is loading and I can acces it at localhost:5600, but no data is being monitored, and the trayicon is not appearing.

More precisely, when I run ./aw-qt, I get the following errors (complete log files are in the Documentation section below):

[WARNING]: Found matching file but was not executable
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'Authorization required, but no authorization protocol specified\\n\'', DisplayConnectionError(':0', b'Authorization required, but no authorization protocol specified\n'))

Try one of the following resolutions:

\* Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified\n'

I already tried some fixes, which are detailed in the Failed fix attempts section below. Mainly: make executable, add to autostart and sudo.

To Reproduce

  1. Download the .zip latest release.
  2. Unzip the archive.
  3. Execute from the terminal ./aw-qt.
  4. Get the errors.

Expected behavior

Install ActivityWatch, with the trayicon, and monitor data.

Documentation

Screenshots from activity and buckets panels

activity buckets

Log files

~/.cache/activitywatch/log/aw-qt/aw-qt_2024-10-14T14-33-10.log

2024-10-14 14:33:10 [INFO ]: Started aw-qt... (aw_qt.main:53)
2024-10-14 14:33:10 [WARNING]: Found matching file but was not executable: /home/taka/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch/aw-server-rust/aw-server.service (aw_qt.manager:64)
2024-10-14 14:33:10 [WARNING]: Found matching file but was not executable: /home/taka/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch/aw-qt.desktop (aw_qt.manager:64)
2024-10-14 14:33:10 [INFO ]: Found 7 bundled modules (aw_qt.manager:85)
2024-10-14 14:33:10 [INFO ]: Found 0 system modules (aw_qt.manager:119)
2024-10-14 14:33:10 [INFO ]: Starting module aw-server (aw_qt.manager:148)
2024-10-14 14:33:10 [INFO ]: Starting module aw-watcher-window (aw_qt.manager:148)
2024-10-14 14:33:10 [INFO ]: Starting module aw-watcher-afk (aw_qt.manager:148)
2024-10-14 14:33:10 [INFO ]: Creating trayicon... (aw_qt.trayicon:208)

~/.cache/activitywatch/log/aw-server/aw-server_2024-10-14T14-33-11.log

2024-10-14 14:33:11 [INFO ]: Using storage method: peewee (aw_server.main:33)
2024-10-14 14:33:11 [INFO ]: Starting up... (aw_server.main:41)
2024-10-14 14:33:11 [INFO ]: Using database file: /home/taka/.local/share/activitywatch/aw-server/peewee-sqlite.v2.db (aw_datastore.storages.peewee:150)
2024-10-14 14:33:11 [INFO ]: WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 \* Running on http://localhost:5600 (werkzeug:187)
2024-10-14 14:33:11 [INFO ]: Press CTRL+C to quit (werkzeug:187)

~/.cache/activitywatch/log/aw-watcher-afk/aw-watcher-afk_2024-10-14T14-33-10.log

2024-10-14 14:33:10 [INFO ]: aw-watcher-afk started (aw_watcher_afk.afk:62)
2024-10-14 14:33:11 [INFO ]: Connection to aw-server established by aw-watcher-afk (aw_client.client:447)
2024-10-14 14:33:12 [ERROR]: Unhandled exception (root:50)
Traceback (most recent call last):
 File "aw_watcher_afk/__main__.py", line 25, in <module>
 File "aw_watcher_afk/__main__.py", line 21, in main
 File "aw_watcher_afk/afk.py", line 72, in run
 File "aw_watcher_afk/afk.py", line 86, in heartbeat_loop
 File "aw_watcher_afk/unix.py", line 41, in seconds_since_last_input
 File "aw_watcher_afk/unix.py", line 14, in __init__
 File "aw_watcher_afk/listeners.py", line 78, in start
 File "PyInstaller/loader/pyimod02_importers.py", line 419, in exec_module
 File "pynput/__init__.py", line 40, in <module>
 File "PyInstaller/loader/pyimod02_importers.py", line 419, in exec_module
 File "pynput/keyboard/__init__.py", line 31, in <module>
 File "pynput/_util/__init__.py", line 76, in backend
ImportError: this platform is not supported: ('failed to acquire X connection: Can\'t connect to display ":0": b\'Authorization required, but no authorization protocol specified\\n\'', DisplayConnectionError(':0', b'Authorization required, but no authorization protocol specified\n'))

Try one of the following resolutions:

\* Please make sure that you have an X server running, and that the DISPLAY environment variable is set correctly

~/.cache/activitywatch/log/aw-watcher-window/aw-watcher-window_2024-10-14T14-33-10.log

2024-10-14 23:31:51 [ERROR]: Exception thrown while trying to get active window (aw_watcher_window.main:133)
Traceback (most recent call last):
 File "aw_watcher_window/main.py", line 115, in heartbeat_loop
 File "aw_watcher_window/lib.py", line 64, in get_current_window
 File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
 File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
 File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
 File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
 File "PyInstaller/loader/pyimod02_importers.py", line 419, in exec_module
 File "aw_watcher_window/xlib.py", line 13, in <module>
 File "Xlib/display.py", line 89, in __init__
 File "Xlib/display.py", line 71, in __init__
 File "Xlib/protocol/display.py", line 166, in __init__
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified\n'
2024-10-14 23:31:52 [ERROR]: Exception thrown while trying to get active window (aw_watcher_window.main:133)
Traceback (most recent call last):
 File "aw_watcher_window/main.py", line 115, in heartbeat_loop
 File "aw_watcher_window/lib.py", line 64, in get_current_window
 File "aw_watcher_window/lib.py", line 8, in get_current_window_linux
 [REPEATING...]

Failed fix attempts

Killing the process

I'm not sure this is a clean way to reinitialize the program, but when I get the errors and the server is still running, I kill the processes aw-server and aw-watcher-window in order to try fixes.

Adding to autostart

I tried following exactly the installation guide, by adding the aw-qt executable to my autostarts application using Ubuntu StartUp application. After restart, I end up with the same result: the server is loading and I can acces it at localhost:5600, but the trayicon is not appearing, and no data is being monitored.

Make executable

Given the two followinwarnings from aw-qt_..._.log:

2024-10-14 14:33:10 [WARNING]: Found matching file but was not executable: /home/taka/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch/aw-server-rust/aw-server.service (aw_qt.manager:64)
2024-10-14 14:33:10 [WARNING]: Found matching file but was not executable: /home/taka/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch/aw-qt.desktop (aw_qt.manager:64)
  1. I made the two files executables with chmod +x and checked they were with ll

  2. I reattempted ./aw-qt

The change in aw-server-rust/aw-server.service has been detected, but not on aw-qt.desktop.

~/.cache/activitywatch/log/aw-qt/aw-qt_2024-10-15T09-13-50.log

2024-10-15 08:59:20 [INFO ]: Started aw-qt... (aw_qt.main:53)
2024-10-15 08:59:20 [WARNING]: Found matching file but was not executable: /home/taka/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch/aw-qt.desktop (aw_qt.manager:64)
2024-10-15 08:59:20 [INFO ]: Found 8 bundled modules (aw_qt.manager:85)
2024-10-15 08:59:20 [INFO ]: Found 0 system modules (aw_qt.manager:119)
2024-10-15 08:59:20 [INFO ]: Starting module aw-server (aw_qt.manager:148)
2024-10-15 08:59:20 [INFO ]: Starting module aw-watcher-afk (aw_qt.manager:148)
2024-10-15 08:59:20 [INFO ]: Starting module aw-watcher-window (aw_qt.manager:148)
2024-10-15 08:59:20 [INFO ]: Creating trayicon... (aw_qt.trayicon:208)

The other logs still present the same content as the ones from the Documentation section.

Sudo

I tried sudo ./aw-qt. Then I get the following output and the server is not even loading.

taka@taka-HP-EliteBook-725-G4:~/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch$ sudo ./aw-qt

2024-10-15 09:10:40 [INFO ]: Started aw-qt... (aw_qt.main:53)
2024-10-15 09:10:40 [WARNING]: Found matching file but was not executable: /home/taka/Téléchargements/activitywatch-v0.13.2-linux-x86_64/activitywatch/aw-qt.desktop (aw_qt.manager:64)
2024-10-15 09:10:40 [INFO ]: Found 8 bundled modules (aw_qt.manager:85)
2024-10-15 09:10:40 [INFO ]: Found 0 system modules (aw_qt.manager:119)
2024-10-15 09:10:40 [INFO ]: Starting module aw-server (aw_qt.manager:148)
2024-10-15 09:10:40 [INFO ]: Starting module aw-watcher-afk (aw_qt.manager:148)
2024-10-15 09:10:40 [INFO ]: Starting module aw-watcher-window (aw_qt.manager:148)
2024-10-15 09:10:41 [INFO ]: Creating trayicon... (aw_qt.trayicon:208)
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: vkkhrdisplay, minimal, minimalegl, wayland, linuxfb, xcb, vnc, wayland-egl, offscreen.

Abandon
github-actions[bot] commented 1 month ago

Hi there! As you're new to this repo, please make sure you've used an appropriate issue template and searched for duplicates (it helps us focus on actual development!). We'd also like to suggest that you read our contribution guidelines and our code of conduct. Thanks a bunch for opening your first issue! 🙏

ErikBjare commented 1 month ago

Looks like you are using Wayland, see: https://github.com/ActivityWatch/activitywatch/issues/92

You should never run aw-qt or any ActivityWatch binary with sudo. There's no need at all.