Ability to change monitor
When using a laptop with an external monitor connected via HDMI, the input field in Hyprlock may appear only on the external monitor. If the external monitor is disconnected, the input field is no longer visible, although unlocking is still possible. It should be possible to dynamically adjust the monitor where the input field appears.
A possible solution is to introduce a configuration option that allows specifying a command to determine which monitor should display the input field. Additionally, a custom script can listen for Hyprland events such as MonitorRemoved and MonitorAdded. When a monitor change is detected, sending SIGUSR2 to Hyprlock would trigger a refresh and reposition the input field on the new monitor.
An alternative approach could involve adding something like the existing reload_time and reload_cmd options, similar to the way image reloading works.
It seems like you have explicitly set a monitor in your input-field section of the hyprlock config. If you you leave the monitor option empty, the input-field will simply appear on both. Something like this,
input-field {
monitor =
#other stuff
}
If this does not work, just share your config for more info.
Yes, if I leave the monitor option empty, the input field appears on all monitors. However, this is not the desired behaviour. I expect the input field to appear only on the HDMI monitor, not on the eDP monitor, under normal conditions. But if I disconnect the HDMI monitor, I want to change the configuration to use only the eDP monitor (or in my case, having it appear on all monitors would also be fine).
Snippet of my configuration:
input-field {
monitor = HDMI-A-1
# other stuff
}
Configuration I want after the HDMI cable is disconnected:
input-field {
monitor =
# other stuff
}
Got it, I don't think hyprland natively supports that sort of conditional logic.
What you can do is create a simple script like this anywhere you want & you need to install socat for this (remember to 'chmod +x' this script to make it an executable), Hyprland Wiki
script_name.sh
#!/bin/bash
handle() {
case $1 in
monitoradded*) sed -i "s/^monitor =.*/monitor = HDMI-A-1/" ~/.config/hypr/hyprlock_inputfield;;
monitorremoved*) sed -i "s/^monitor =.*/monitor = /" ~/.config/hypr/hyprlock_inputfield;;
esac
}
socat -U - UNIX-CONNECT:$XDG_RUNTIME_DIR/hypr/$HYPRLAND_INSTANCE_SIGNATURE/.socket2.sock | while read -r line; do handle "$line"; done
and exec-once=/the/script & in your hyprland config.
Move the input field section (or whatever else whose monitor setting you need to change) to a separate file(in the example script i used hyprlock_inputfield).
Use source= /path/to/that/file in your hyprlock config
Thanks for the suggestion! I tried your approach, and it works well for generating a script that can reload the configuration. However, as you mentioned, this probably can't be done dynamically if the screen is already locked - Hyprland likely doesn't support this functionality. Since dynamic monitor switching while locked isn't feasible, this issue can be closed.
I don't fully agree. I think a special value for monitor= that encodes that the user would like to keeps this on the "primary" monitor.
Since primary monitors don't exist in wayland we would have to come up with a way to express what we want.
Maybe a system where you declare monitor=primary and monitor=secondary and you can somehow specify preferred primary monitors in the hyprlock config as well. In case no preferred monitor is connected, it would pick the first monitor as the primary and treat others as secondary.
Could be useful, but wouldn't that need to be made in hyprlang or utils? Considering that will be shared among the hypr-ecosystem.
You are right. Since the concept could be useful in other applications too, it would make sense. Actually we are moving hyprlock to hyprtoolkit, which would be the right place for a primary monitor concept I think.