awatcher
awatcher copied to clipboard
I can't seem to get awatcher running without manually invoking it.
Version of awatcher used:
Bundle
❯ awatcher --version
Activity Watcher 0.3.1
Things I have tried:
placing awatcher.desktop in ~/.config/autostart/
awatcher.desktop:
Exec=sh -c '/usr/bin/awatcher --no-tray &'
no sign of awatcher running
invoking awatcher in my i3 config:
exec --no-startup-id alacritty --class "awatcher" -e /usr/bin/awatcher --no-tray
alacritty window closes immediately on startup
invoking awatcher inside of a headless alacritty instance via my i3-config:
exec --no-startup-id alacritty --daemon --class "awatcher" -e /usr/bin/awatcher --no-tray
awatcher process doesn't exist, even though the alacritty process exists - checked with
ps -ef | grep -i awa
awatcher only launches when I invoke it manually, idk why 😭
and I need a window open, for it to work. Even if I summon an alacritty daemon manually it doesn't work
or if I do a sh -c awatcher --no-tray & it needs at least one terminal window open it seems, and I have no idea why.
Same thing happens to me. I added aw-qt to autostart, and it does run the server as I can access it at localhost:5600, however the watcher is not running and ps aux | grep aw- tells that it is <defunct> (command is [aw-awatcher] <defunct>)
@k2helix Do you have i3 DE too?
@ndrew222 @k2helix I think we need to see the logs with -vvv argument. To see them, add -vvv to the arguments, then as I mentioned earlier:
Your system is probably using systemd, so this might work:
journalctl --user --no-pager --since "1 day ago" | grep awatcher
or this
sudo grep -i awatcher /var/log/syslog
If it doesn't post logs in your setup, you can make it a service like described in https://github.com/2e3s/awatcher/issues/11
Same problem with starting awatcher (v0.3.1 - none bundle) in Sway (like i3 window manager but for Wayland).
When shepherd ('systemd' of linux Guix) tries to start awatcher it exits. It is a home shepherd service so i believe it starts it as a current user. Here is the log:
2025-04-11 00:40:20 [2025-04-10 22:40:20.283752 INFO awatcher] Sending to server 127.0.0.1:5600
2025-04-11 00:40:20 [2025-04-10 22:40:20.283790 INFO awatcher] Idle timeout: 180 seconds
2025-04-11 00:40:20 [2025-04-10 22:40:20.283792 INFO awatcher] Idle polling period: 5 seconds
2025-04-11 00:40:20 [2025-04-10 22:40:20.283794 INFO awatcher] Window polling period: 1 seconds
2025-04-11 00:40:20 [2025-04-10 22:40:20.310543 DEBUG watchers::watchers] Watcher "Wayland idle (ext-idle-notify-v1)" cannot run: Unable to connect to Wayland compositor
2025-04-11 00:40:20 [2025-04-10 22:40:20.310564 DEBUG watchers::watchers] Watcher "Wayland idle (KDE)" cannot run: Unable to connect to Wayland compositor
2025-04-11 00:40:20 [2025-04-10 22:40:20.310567 WARN watchers::watchers::x11_connection] DISPLAY is not set, setting to the default value ":0"
2025-04-11 00:40:20 [2025-04-10 22:40:20.310990 DEBUG watchers::watchers] Watcher "X11 idle (screensaver)" cannot run: Unsupported extension
2025-04-11 00:40:20 [2025-04-10 22:40:20.311158 DEBUG watchers::watchers] Watcher "Wayland window (wlr-foreign-toplevel-management-unstable-v1)" cannot run: Unable to connect to Wayland compositor
2025-04-11 00:40:20 [2025-04-10 22:40:20.316359 DEBUG watchers::watchers] Watcher "Gnome idle (Mutter/IdleMonitor)" cannot run: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Mutter.IdleMonitor was not provided by any .service files
When i start manually with the same command aw-awatcher -vvv from cli it runs normally:
[2025-04-13 21:12:33.491039 INFO awatcher] Sending to server 127.0.0.1:5600
[2025-04-13 21:12:33.491083 INFO awatcher] Idle timeout: 180 seconds
[2025-04-13 21:12:33.491088 INFO awatcher] Idle polling period: 5 seconds
[2025-04-13 21:12:33.491091 INFO awatcher] Window polling period: 1 seconds
[2025-04-13 21:12:33.519302 INFO watchers::watchers] Selected watcher: Wayland idle (ext-idle-notify-v1)
[2025-04-13 21:12:33.519322 INFO watchers::watchers] Starting idle watcher
[2025-04-13 21:12:33.519823 DEBUG watchers::watchers::wl_foreign_toplevel_management] Toplevel handle is received zwlr_foreign_toplevel_handle_v1@4278190080
[2025-04-13 21:12:33.519865 DEBUG watchers::watchers::wl_foreign_toplevel_management] Toplevel handle is received zwlr_foreign_toplevel_handle_v1@4278190081
[2025-04-13 21:12:33.519884 INFO watchers::watchers] Selected watcher: Wayland window (wlr-foreign-toplevel-management-unstable-v1)
[2025-04-13 21:12:33.519888 INFO watchers::watchers] Starting active window watcher
What am i missing?
Thank you for logs @buttonspresser It shows that the data is not available yet, I guess. This happens within some running systems, which is why we have introduced a delay for starting https://github.com/2e3s/awatcher/blob/main/config/aw-awatcher.service Does you runner have something like that?
This being so common makes me thinking about integrating the delay configuration into the watcher.
@k2helix Do you have i3 DE too?
Sorry for the late answer, I didn't have time last weeks.
No, I was using GNOME where this seemed random as it sometimes started fine and sometimes didn't and had to do it manually. But I recently switched to KDE and it also happened there.
I can provide logs if they are needed, although I didn't make it a systemd service.
However, I can confirm after some days that adding a sleep 5 before aw-qt on the autostart script (a .sh file that can be added on KDE autostart settings) seems to do it as it has been working without trouble.
I am experiencing the same issues as @k2helix, I resorted to a 30 second delay, just to be safe, but it still happens from time to time. I can provide the logs too if needed. This behavior motivated https://github.com/ActivityWatch/aw-tauri/issues/120 but it's nice you are considering implementing the delay directly to awatcher.
Yes @2e3s, my experiments show that the problem is 'missing data' indeed and it was the WAYLAND_DISPLAY environment variable.
I tried to delay the start of awatcher service but it does not help. Nether did restarting the service. I use shepherd (service manager of Linux Guix) and it seems that it is not aware of the sway environment probably because sway starts after the shepherd.
So for those who use Guix, here is the definition of awatcher shepherd service that can work:
(shepherd-service
(provision '(aw-awatcher))
;; aw-server service should be defined
(requirement '(aw-server))
(documentation "Runs aw-awatcher - activity and idle watchers.")
(respawn? #t)
(respawn-delay 10)
(start #~(make-forkexec-constructor
(list
;; activitywatch-awatcher package should be defined
#$(file-append activitywatch-awatcher "/bin/aw-awatcher") "-vvv")
#:log-file "~/.local/state/awatcher.log"
#:environment-variables (append
(default-environment-variables)
'("WAYLAND_DISPLAY=wayland-1"))))
(stop #~(make-kill-destructor)))
It works for now but i do not like that i set this variable 'manually'. Preferably i would import the actual sway environment but i have not yet figure it out. Here is the relevant thread on Guix mailing list - Shepherd environment question