mirror of
https://github.com/arthur-pbty/arthur-os.git
synced 2026-08-01 20:28:16 +02:00
* Add omarchy CLI * Remove outdated or internal * Add bash completions for command * Add omarchy command documentation * Add missing docs * Correct to what's now right * Fix tests --------- Co-authored-by: David Heinemeier Hansson <david@hey.com>
47 lines
1.3 KiB
Bash
Executable File
47 lines
1.3 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# omarchy:summary=Adjust brightness on the most likely display device.
|
|
# omarchy:args=<step>
|
|
|
|
step="${1:-+5%}"
|
|
|
|
# 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
|
|
if [[ -e /sys/class/backlight/$candidate ]]; then
|
|
device="$candidate"
|
|
break
|
|
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
|
|
|
|
# Use SwayOSD to display the new brightness setting.
|
|
omarchy-swayosd-brightness "$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')"
|