The lock service arms a 5s blank timer whenever the screen locks, and input at the lock screen re-arms it. Closing the lid sprays pointer noise over the lock surface, so the timer was routinely armed right before suspend, froze mid-countdown, and fired moments after resume -- blanking the freshly woken unlock screen under the user. Guard the timer with a wall-clock check: if far more time elapsed than the interval, the countdown slept through a suspend, so take a fresh run-up instead of blanking. This also blanks the lock screen 5s after an untouched resume. Two accomplices made the flash worse and hid the real bug: - The clamshell watcher's 2s poll fired an unconditional global DPMS enable whenever no external monitor was active, relighting any blank within 2 seconds (lock-screen blanking never stuck on undocked laptops) and racing the resume modeset. Recovery now only wakes displays when it actually re-enables one. - Every keystroke at the lock screen dispatched a redundant DPMS enable via omarchy-system-wake, forcing extra modesets in the fragile just-resumed DRM state. Brightness "on" now skips the dispatch when every active display is already lit. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
89 lines
2.7 KiB
Bash
Executable File
89 lines
2.7 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Show or adjust brightness on the most likely display device.
|
|
# omarchy:args=[--no-osd] [+N%|N%-|N%|off|on]
|
|
# omarchy:examples=omarchy brightness display | omarchy brightness display +5% | omarchy brightness display --no-osd 50% | omarchy brightness display off | omarchy brightness display on
|
|
|
|
no_osd=0
|
|
if [[ ${1:-} == "--no-osd" ]]; then
|
|
no_osd=1
|
|
shift
|
|
fi
|
|
|
|
# Get the brightness of the passed display
|
|
display_brightness() {
|
|
brightnessctl -d "$1" -m 2>/dev/null | awk -F, '{ gsub("%", "", $4); print $4; found=1 } END{ exit !found }'
|
|
}
|
|
|
|
if (( $# == 0 )); then
|
|
if omarchy-hyprland-monitor-focused-apple; then
|
|
omarchy-brightness-display-apple
|
|
exit
|
|
fi
|
|
|
|
device="$(omarchy-hw-display)" || exit 1
|
|
display_brightness "$device"
|
|
exit
|
|
fi
|
|
|
|
step="$1"
|
|
|
|
if [[ $step == "off" ]]; then
|
|
hyprctl dispatch 'hl.dsp.dpms({ action = "disable" })' >/dev/null 2>&1
|
|
exit 0
|
|
elif [[ $step == "on" ]]; then
|
|
# Skip the dispatch when every active display is already lit: a redundant
|
|
# DPMS enable right after system resume forces another modeset, which blanks
|
|
# the panel for a beat (visible flash at the unlock screen).
|
|
hyprctl monitors -j 2>/dev/null | jq -e '[.[] | select(.disabled == false)] | length > 0 and all(.dpmsStatus)' >/dev/null 2>&1 && exit 0
|
|
hyprctl dispatch 'hl.dsp.dpms({ action = "enable" })' >/dev/null 2>&1
|
|
exit 0
|
|
fi
|
|
|
|
# Drop overlapping brightness key events so concurrent invocations do not race.
|
|
# Hardware key repeat present on some devices can otherwise glitch OSD rendering.
|
|
exec {lock_fd}>"${XDG_RUNTIME_DIR:-/tmp}/omarchy-brightness-display.lock"
|
|
flock -n "$lock_fd" || exit 0
|
|
|
|
if omarchy-hyprland-monitor-focused-apple; then
|
|
if (( no_osd )); then
|
|
omarchy-brightness-display-apple --no-osd "$step"
|
|
else
|
|
omarchy-brightness-display-apple "$step"
|
|
fi
|
|
else
|
|
# Current device highlighted
|
|
device="$(omarchy-hw-display)" || exit 1
|
|
|
|
# Current brightness percentage
|
|
current=$(display_brightness "$device") || exit 1
|
|
|
|
# Apply non-uniform step size: 1% steps if at or below 5%, otherwise set an
|
|
# absolute target percentage to avoid raw backlight rounding causing uneven OSD steps.
|
|
if [[ $step == "+5%" ]]; then
|
|
if (( current < 5 )); then
|
|
(( target = current + 1 ))
|
|
else
|
|
(( target = current + 5 ))
|
|
fi
|
|
|
|
(( target > 100 )) && target=100
|
|
step="$target%"
|
|
elif [[ $step == "5%-" ]]; then
|
|
if (( current <= 5 )); then
|
|
(( target = current - 1 ))
|
|
else
|
|
(( target = current - 5 ))
|
|
fi
|
|
|
|
(( target < 1 )) && target=1
|
|
step="$target%"
|
|
fi
|
|
|
|
# Set brightness of the display device.
|
|
brightnessctl -d "$device" set "$step" >/dev/null
|
|
|
|
# Show the new brightness in OSD
|
|
(( no_osd )) || omarchy-osd -i brightness -p "$(display_brightness "$device")"
|
|
fi
|