2e3s / awatcher

Activity and idle watchers
Mozilla Public License 2.0
126 stars 4 forks source link

Does not work with Hyprland? #6

Closed jonas-w closed 9 months ago

jonas-w commented 9 months ago

I have switched to Hyprland a few days ago (previously on sway).

And I just noticed, that the awatcher service immediately exits with code 0.

Below the output if I launch awatcher in my terminal: $ awatcher -vvvvv

[2023-11-30 02:07:16.683784 INFO awatcher] Sending to server localhost:5600
[2023-11-30 02:07:16.683795 INFO awatcher] Idle timeout: 180 seconds
[2023-11-30 02:07:16.683797 INFO awatcher] Idle polling period: 5 seconds
[2023-11-30 02:07:16.683798 INFO awatcher] Window polling period: 1 seconds
[2023-11-30 02:07:16.694126 DEBUG watchers::watchers] wl_kwin_idle::IdleWatcher cannot run: the requested global was not found in the registry
[2023-11-30 02:07:16.694338 DEBUG watchers::watchers] x11_screensaver_idle::IdleWatcher cannot run: Unsupported extension
[2023-11-30 02:07:16.694610 DEBUG watchers::watchers::wl_foreign_toplevel] Toplevel handle is received zwlr_foreign_toplevel_handle_v1@4278190080
[2023-11-30 02:07:16.694615 DEBUG watchers::watchers::wl_foreign_toplevel] Toplevel handle is received zwlr_foreign_toplevel_handle_v1@4278190081
[2023-11-30 02:07:16.694617 DEBUG watchers::watchers::wl_foreign_toplevel] Toplevel handle is received zwlr_foreign_toplevel_handle_v1@4278190082
[2023-11-30 02:07:16.694620 TRACE watchers::watchers::wl_foreign_toplevel] Title is changed for zwlr_foreign_toplevel_handle_v1@4278190080: New Issue · 2e3s/awatcher — Mozilla Firefox
[2023-11-30 02:07:16.694621 TRACE watchers::watchers::wl_foreign_toplevel] App ID is changed for zwlr_foreign_toplevel_handle_v1@4278190080: firefox
[2023-11-30 02:07:16.694623 TRACE watchers::watchers::wl_foreign_toplevel] State is changed for zwlr_foreign_toplevel_handle_v1@4278190080: []
[2023-11-30 02:07:16.694625 TRACE watchers::watchers::wl_foreign_toplevel] Done: zwlr_foreign_toplevel_handle_v1@4278190080
[2023-11-30 02:07:16.694627 TRACE watchers::watchers::wl_foreign_toplevel] Title is changed for zwlr_foreign_toplevel_handle_v1@4278190081: coshr 'awatcher -vvvvv'
[2023-11-30 02:07:16.694628 TRACE watchers::watchers::wl_foreign_toplevel] App ID is changed for zwlr_foreign_toplevel_handle_v1@4278190081: footclient
[2023-11-30 02:07:16.694630 TRACE watchers::watchers::wl_foreign_toplevel] State is changed for zwlr_foreign_toplevel_handle_v1@4278190081: [2, 0, 0, 0]
[2023-11-30 02:07:16.694632 TRACE watchers::watchers::wl_foreign_toplevel] Window is activated: zwlr_foreign_toplevel_handle_v1@4278190081
[2023-11-30 02:07:16.694633 TRACE watchers::watchers::wl_foreign_toplevel] Done: zwlr_foreign_toplevel_handle_v1@4278190081
[2023-11-30 02:07:16.694635 TRACE watchers::watchers::wl_foreign_toplevel] Title is changed for zwlr_foreign_toplevel_handle_v1@4278190082: foot
[2023-11-30 02:07:16.694636 TRACE watchers::watchers::wl_foreign_toplevel] App ID is changed for zwlr_foreign_toplevel_handle_v1@4278190082: footclient
[2023-11-30 02:07:16.694638 TRACE watchers::watchers::wl_foreign_toplevel] State is changed for zwlr_foreign_toplevel_handle_v1@4278190082: []
[2023-11-30 02:07:16.694639 TRACE watchers::watchers::wl_foreign_toplevel] Done: zwlr_foreign_toplevel_handle_v1@4278190082
[2023-11-30 02:07:16.694641 INFO watchers::watchers] Selected wl_foreign_toplevel::WindowWatcher as active window watcher
[2023-11-30 02:07:16.694648 INFO watchers::watchers] Starting active window watcher
[2023-11-30 02:07:16.694670 TRACE watchers::report_client] Reporting app_id: footclient, title: coshr 'awatcher -vvvvv'
[2023-11-30 02:07:16.695404 DEBUG watchers::watchers] gnome_idle::IdleWatcher cannot run: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Mutter.IdleMonitor was not provided by any .service files

It seems to find my active windows, but then exits because of something with gnome?? I don't have gnome installed, though I have nautilus installed which pulls some gnome dependencies, but I also had it installed previously in sway, so this shouldn't be the problem?

2e3s commented 9 months ago

Hi, thank you for your report. If it worked in Sway, then Hyprland should show be the same if it supports the necessary protocols. It doesn't seem that it does:

[2023-11-30 02:07:16.694126 DEBUG watchers::watchers] wl_kwin_idle::IdleWatcher cannot run: the requested global was not found in the registry
[2023-11-30 02:07:16.694338 DEBUG watchers::watchers] x11_screensaver_idle::IdleWatcher cannot run: Unsupported extension
[2023-11-30 02:07:16.695404 DEBUG watchers::watchers] gnome_idle::IdleWatcher cannot run: org.freedesktop.DBus.Error.ServiceUnknown: The name org.gnome.Mutter.IdleMonitor was not provided by any .service files

Only those 3 types are supported. It's still impossible to enable or disable idle and window watchers individually, so after attempt to access Gnome interface it just stops. Sway supports this protocol https://wayland.app/protocols/kde-idle Maybe this would work? https://wayland.app/protocols/ext-idle-notify-v1 The interface seems nearly the same as KWin idle, so I'm implementing it now.

Please, run wayland-info | grep idle. It is available on many distributions: https://gitlab.freedesktop.org/wayland/wayland-utils#wayland-info Here's my output in KDE:

$ wayland-info | grep idle
interface: 'org_kde_kwin_idle',                          version:  1, name: 19
interface: 'zwp_idle_inhibit_manager_v1',                version:  1, name: 20
interface: 'ext_idle_notifier_v1',                       version:  1, name: 21
2e3s commented 9 months ago

Quick testing shows that this protocol works too, so you could try if you have it https://github.com/2e3s/awatcher/releases/tag/v0.2.4-alpha1

jonas-w commented 9 months ago

@2e3s gee, that was fast, thank you!

Though it never shows as idle. I'm running it with -vvvvv, and it always just prints "Reporting as not idle", until swaylock pops up after 60s. swayidle works correctly on Hyprland (i.e. it opens swaylock after 60s because I said so), and it also uses ext-idle-notify

2e3s commented 9 months ago

The default idle timeout is 180 second. Maybe try to run with --idle-timeout=10 or more. It can be changed through CLI or at .config/awatcher/config.toml. But I'm confused what's the problem, or is there a problem yet with the protocols support?

By the way, -vvv is enough to track the switch to idle or resumed state.

jonas-w commented 9 months ago

Ooh, feeling pretty dumb right now, thanks! Didn't realize that awatcher has an idle timeout! Thank you, works as expected ^^