Hi,
I wonder if there is an easy way to configure Hyprland, Hypridle, and Hyprlock so that when I press, say, Alt+Ctrl+L, the screen locks and the monitor turns off.
The first step - locking the screen - is straightforward:
exec-once = hypridle
bind = ALT CTRL, l, exec, loginctl lock-session
However, this does not turn off the monitor immediately; it will only do so once Hypridle’s timeout expires (see the configuration below).
I tried using a simple script, lock.sh (see below), and binding it instead, and it works. However, the screen does not turn on when a key is pressed, but only after the timeout expires.
unlock.sh:
#!/bin/bash
hyprctl dispatch dpms off
loginctl lock-session
Thanks,
PS. For reference, here is my hypridle.config:
general {
lock_cmd = pidof hyprlock || hyprlock # avoid starting multiple hyprlock instances.
before_sleep_cmd = loginctl lock-session # lock before suspend.
after_sleep_cmd = hyprctl dispatch dpms on # to avoid having to press a key twice to turn on the display.
}
listener {
timeout = 300 # 5min
on-timeout = loginctl lock-session # lock screen when timeout has passed
}
listener {
timeout = 330 # 5.5min
on-timeout = hyprctl dispatch dpms off # screen off when timeout has passed
on-resume = hyprctl dispatch dpms on # screen on when activity is detected after timeout has fired.
}