From 1acaa7ba4da1ce089936cb4bc730d280bd0c93f4 Mon Sep 17 00:00:00 2001 From: Mateusz Kowalczyk Date: Mon, 11 May 2026 16:33:58 +0200 Subject: [PATCH] Fix brightness indicator glitches caused by hardware-side key auto-repeat (#5760) * Avoid overlapping brightness change key events. * Clarify the fix comment --- bin/omarchy-brightness-display | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/bin/omarchy-brightness-display b/bin/omarchy-brightness-display index 193bdb1b..7d30bfcf 100755 --- a/bin/omarchy-brightness-display +++ b/bin/omarchy-brightness-display @@ -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