Fix brightness indicator glitches caused by hardware-side key auto-repeat (#5760)

* Avoid overlapping brightness change key events.

* Clarify the fix comment
This commit is contained in:
Mateusz Kowalczyk
2026-05-11 16:33:58 +02:00
committed by GitHub
parent dc4e6a6a50
commit 1acaa7ba4d
+15 -8
View File
@@ -6,6 +6,21 @@
step="${1:-+5%}"
if [[ $step == "off" ]]; then
hyprctl dispatch dpms off >/dev/null 2>&1
exit 0
elif [[ $step == "on" ]]; then
hyprctl dispatch dpms on >/dev/null 2>&1
exit 0
fi
runtime_dir="${XDG_RUNTIME_DIR:-/tmp}"
# Drop overlapping brightness key events so concurrent invocations do not race.
# Hardware key repeat present on some devices can otherwise glitch SwayOSD rendering.
exec 9>"$runtime_dir/omarchy-brightness-display.lock"
flock -n 9 || exit 0
# Start with the first possible output, then refine to the most likely given an order heuristic.
device="$(ls -1 /sys/class/backlight 2>/dev/null | head -n1)"
for candidate in amdgpu_bl* intel_backlight acpi_video*; do
@@ -15,14 +30,6 @@ for candidate in amdgpu_bl* intel_backlight acpi_video*; do
fi
done
if [[ $step == "off" ]]; then
hyprctl dispatch dpms off >/dev/null 2>&1
exit 0
elif [[ $step == "on" ]]; then
hyprctl dispatch dpms on >/dev/null 2>&1
exit 0
fi
if omarchy-hyprland-monitor-focused-apple; then
omarchy-brightness-display-apple "$step"
exit