I’m experiencing an issue with swaylock and hyprlock where my screen brightness settings are disrupted upon locking the screen.
When I use swaylock or hyprlock to lock my screen, they trigger the swayidle or hypridle resume event upon startup. As a result, if my swayidle or hypridle configuration includes settings to dim or turn off the screen after a timeout, the screen brightness unexpectedly restores when the lock screen activates. This disrupts my intended screen brightness management during idle periods.
Below are my current hypridle and swayidle configurations:
With these configurations, when swaylock or hyprlock starts, it triggers the on-resume or resume events in hypridle or swayidle, causing the screen brightness to unexpectedly restore.
Has anyone else encountered this issue? If so, how did you resolve it? I am looking for any suggestions or configuration tips that can prevent swaylock or hyprlock from triggering the resume event and causing the screen brightness to reset.
I managed to resolve the issue with swaylock and hyprlock triggering the idle resume event and disrupting screen brightness. Below are the configurations for both swayidle and hypridle that worked for me.
#!/bin/bash
# Check if swaylock is running
if pidof swaylock >/dev/null; then
# Get the first process ID of swaylock
pid=$(pgrep -o swaylock)
# Check the elapsed time since the process started
elapsed_time=$(ps -p "$pid" -o etimes= | tr -d ' ')
# If the elapsed time is greater than 1 second
if [ "$elapsed_time" -gt 1 ]; then
# Restore the screen brightness from /tmp/bn
brightness=$(cat /tmp/bn)
brightnessctl set "$brightness"
# Turn on the DPMS (Display Power Management Signaling) to ensure the display is active
hyprctl dispatch dpms on
fi
fi
To enable:
exec brightnessctl g > /tmp/bn && swayidle -C /path/to/swayidle-config
These configurations ensure that the screen brightness is managed correctly and that the display is not unexpectedly turned on during locking. If anyone else faces a similar issue, I hope this helps.