hypridle: Doesn't work till locked once manually.

Config

general {
    lock_cmd = swaylock -f                           
    unlock_cmd = killall -q -s SIGUSR1 swaylock       
    before_sleep_cmd = loginctl lock-session; sleep 2  
    ignore_dbus_inhibit = false        
}

listener {
    timeout = 10                          
    on-timeout = swaylock -f
}

listener {
    timeout = 20                                          
    on-timeout = sleep 1 && hyprctl dispatch dpms off       
    on-resume = sleep 1 && hyprctl dispatch dpms on         
}

listener {
    timeout = 30                                          
    on-timeout = systemctl suspend
}

# vim: commentstring=#\ %s

Logs

󰘧 killall hypridle; hypridle
[LOG] Registered timeout rule for 10s:
      on-timeout: swaylock -f
      on-resume:
[LOG] Registered timeout rule for 20s:
      on-timeout: sleep 1 && hyprctl dispatch dpms off
      on-resume: sleep 1 && hyprctl dispatch dpms on
[LOG] Registered timeout rule for 30s:
      on-timeout: systemctl suspend
      on-resume:
[LOG]   | got iface: wl_shm v1
[LOG]   | got iface: wl_drm v2
[LOG]   | got iface: zwp_linux_dmabuf_v1 v4
[LOG]   | got iface: wl_compositor v6
[LOG]   | got iface: wl_subcompositor v1
[LOG]   | got iface: wl_data_device_manager v3
[LOG]   | got iface: zwlr_export_dmabuf_manager_v1 v1
[LOG]   | got iface: zwlr_data_control_manager_v1 v2
[LOG]   | got iface: zwp_primary_selection_device_manager_v1 v1
[LOG]   | got iface: wp_viewporter v1
[LOG]   | got iface: zwlr_gamma_control_manager_v1 v1
[LOG]   | got iface: zwlr_output_power_manager_v1 v1
[LOG]   | got iface: xdg_wm_base v6
[LOG]   | got iface: wl_seat v9
[LOG]    > Bound to wl_seat v9
[LOG]   | got iface: wp_presentation v1
[LOG]   | got iface: ext_idle_notifier_v1 v1
[LOG]    > Bound to ext_idle_notifier_v1 v1
[LOG]   | got iface: zwlr_layer_shell_v1 v4
[LOG]   | got iface: org_kde_kwin_server_decoration_manager v1
[LOG]   | got iface: zxdg_decoration_manager_v1 v1
[LOG]   | got iface: zwlr_output_manager_v1 v4
[LOG]   | got iface: zwp_keyboard_shortcuts_inhibit_manager_v1 v1
[LOG]   | got iface: zwp_pointer_constraints_v1 v1
[LOG]   | got iface: zwp_relative_pointer_manager_v1 v1
[LOG]   | got iface: zwp_virtual_keyboard_manager_v1 v1
[LOG]   | got iface: zwlr_virtual_pointer_manager_v1 v2
[LOG]   | got iface: zwlr_foreign_toplevel_manager_v1 v3
[LOG]   | got iface: wp_drm_lease_device_v1 v1
[LOG]   | got iface: zwp_tablet_manager_v2 v1
[LOG]   | got iface: zwp_idle_inhibit_manager_v1 v1
[LOG]   | got iface: zxdg_exporter_v1 v1
[LOG]   | got iface: zxdg_importer_v1 v1
[LOG]   | got iface: zxdg_exporter_v2 v1
[LOG]   | got iface: zxdg_importer_v2 v1
[LOG]   | got iface: zwp_pointer_gestures_v1 v3
[LOG]   | got iface: zwp_text_input_manager_v3 v1
[LOG]   | got iface: zwp_input_method_manager_v2 v1
[LOG]   | got iface: xdg_activation_v1 v1
[LOG]   | got iface: ext_session_lock_manager_v1 v1
[LOG]   | got iface: wp_cursor_shape_manager_v1 v1
[LOG]   | got iface: wp_tearing_control_manager_v1 v1
[LOG]   | got iface: wp_single_pixel_buffer_manager_v1 v1
[LOG]   | got iface: xwayland_shell_v1 v1
[LOG]   | got iface: hyprland_toplevel_export_manager_v1 v2
[LOG]   | got iface: wp_fractional_scale_manager_v1 v1
[LOG]   | got iface: zwp_text_input_manager_v1 v1
[LOG]   | got iface: hyprland_global_shortcuts_manager_v1 v1
[LOG]   | got iface: zwlr_screencopy_manager_v1 v3
[LOG]   | got iface: zxdg_output_manager_v1 v3
[LOG]   | got iface: wl_output v4
[LOG]   | got iface: wl_output v4
[LOG] found 3 rules
[LOG] wayland done, registering dbus
[LOG] Using dbus path /org/freedesktop/login1/session/_310

This is the log and it keeps like this and nothing happens waited much long enough.

now if i lock the screen manually by issuing the command loginctl lock-session

[LOG] Got dbus .Session
[LOG] Got Lock from dbus
[LOG] Locking with swaylock -f
[LOG] Executing swaylock -f
[LOG] Process Created with pid 1404604

The logs add these few lines.

after this when i unlock everything works fine as expected.

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Reactions: 2
  • Comments: 16 (9 by maintainers)

Most upvoted comments

patch.txt try this

seems to be working for me just fine, your config

For those who don’t want to patch code, I found that it is enough to run it like that:

(hypridle &) && loginctl unlock-session @DonPiotr

Or just use the latest version with the fix lol

I can also replicate this issue, the first commit this occurs on is 36d7238afdcbb04487212304fcbfa23e9d7bac27 (adding dbus support).

From my quick testing, I was able to figure out that the while loop in CHypridle::enterEventLoop (the 2nd one, not the one running in the thread) waits at this function call:

            m_sEventLoopInternals.loopSignal.wait(lk, [this] { return m_sEventLoopInternals.shouldProcess == true; }); // wait for events

which appears to be blocking until the manual lock-session occurs.

Details

Running with this patch, introducing some debug prints:

diff --git a/src/core/Hypridle.cpp b/src/core/Hypridle.cpp
index af317e8..34b61ba 100644
--- a/src/core/Hypridle.cpp
+++ b/src/core/Hypridle.cpp
@@ -101,6 +101,7 @@ void CHypridle::enterEventLoop() {

   std::thread pollThr([this, &pollfds]() {
       while (1) {
+            Debug::log(LOG, "(Thread loop) Poll");
           int ret = poll(pollfds, m_sDBUSState.screenSaverServiceConnection ? 3 : 2, 5000 /* 5 seconds, reasonable. It's because we might need to terminate */);
           if (ret < 0) {
               Debug::log(CRIT, "[core] Polling fds failed with {}", errno);
@@ -133,8 +134,11 @@ void CHypridle::enterEventLoop() {
       m_sEventLoopInternals.loopRequestMutex.unlock(); // unlock, we are ready to take events

       std::unique_lock lk(m_sEventLoopInternals.loopMutex);
-        if (m_sEventLoopInternals.shouldProcess == false) // avoid a lock if a thread managed to request something already since we .unlock()ed
+        if (m_sEventLoopInternals.shouldProcess == false) { // avoid a lock if a thread managed to request something already since we .unlock()ed
+            Debug::log(LOG, "---> BLOCK");
           m_sEventLoopInternals.loopSignal.wait(lk, [this] { return m_sEventLoopInternals.shouldProcess == true; }); // wait for events
+            Debug::log(LOG, "---> DONE");
+        }

       m_sEventLoopInternals.loopRequestMutex.lock(); // lock incoming events

Here’s the output from hypridle -v built with this patch.

Letting it run for a while, this was the output::

[LOG] ---> BLOCK
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll

Now, pretty much immediately after executing loginctl lock-session, this was the output:

[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[LOG] ---> DONE
[TRACE] got dbus event
[TRACE] [core] got poll event
[LOG] Got dbus .Session
[LOG] Got Lock from dbus
[LOG] ---> BLOCK
[LOG] (Thread loop) Poll
[LOG] ---> DONE
[TRACE] got dbus event
[LOG] ---> BLOCK
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[LOG] [TRACE] ---> DONE[core] got poll event
[TRACE] got wl event
[LOG] ---> BLOCK
[LOG] (Thread loop) Poll
[LOG] ---> DONE
[TRACE] got wl event
[LOG] ---> BLOCK

Then, for a while, it ran similarly as before, until the 20s I have configured for my listener have elapsed, after which it now actually processed that and ran the configured command:

[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[LOG] [TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] ---> DONE
[TRACE] got wl event
(Thread loop) Poll
[LOG] Idled: rule 5933692e56c0
[LOG] Running notify-send "HyprIdle" "timeout"
[LOG] Executing notify-send "HyprIdle" "timeout"
[LOG] Process Created with pid 227199
[LOG] ---> BLOCK
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[LOG[] TRACE] [core] got poll event
[LOG] (Thread loop) Poll
[TRACE] ---> DONE[core] got poll event
[TRACE] got wl event

[LOG] Resumed: rule 5933692e56c0
[LOG] Running notify-send "HyprIdle" "resumed"
[LOG] Executing notify-send "HyprIdle" "resumed"
[LOG] Process Created with pid 227290
[LOG] ---> BLOCK
[LOG] (Thread loop) Poll
[LOG] ---> DONE
[TRACE] got wl event
[LOG] ---> BLOCK