mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
Implement non-uniform brightness step adjustments (#5525)
* Implement non-uniform brightness step adjustments Add logic for non-uniform step size adjustments based on current brightness level. * Ensure percentages are moved in a consistent manner so we don't get rounding errors * Ensure we don't go below 1% To prevent screen from turning off entirely on some models --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
co-authored by
David Heinemeier Hansson
parent
69ddcfdf2e
commit
c078d7ad05
@@ -14,6 +14,31 @@ for candidate in amdgpu_bl* intel_backlight acpi_video*; do
|
||||
fi
|
||||
done
|
||||
|
||||
# Current brightness percentage
|
||||
current=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
|
||||
|
||||
# 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 the actual brightness of the display device.
|
||||
brightnessctl -d "$device" set "$step" >/dev/null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user