Set brightness in a more broadly compatible way

Fixes brightness setting on the Asus G14
This commit is contained in:
David Heinemeier Hansson
2026-01-14 16:37:22 -05:00
parent 05b82cbee5
commit 291786d36a
2 changed files with 33 additions and 4 deletions

29
bin/omarchy-cmd-brightness Executable file
View File

@@ -0,0 +1,29 @@
#!/bin/bash
# Adjust brightness on the most likely display device.
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
# Set the actual brightness of the display device.
brightnessctl -d "$device" set "$step" >/dev/null
# Use SwayOSD to display the new brightness setting.
current=$(brightnessctl -d "$device" g)
max=$(brightnessctl -d "$device" m)
percent=$(( current * 100 / max ))
progress=$(awk -v c="$current" -v m="$max" 'BEGIN{printf "%.2f", c/m}')
swayosd-client \
--monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \
--custom-icon display-brightness \
--custom-progress "$progress" \
--custom-progress-text "${percent}%"