Extract turning brightness devices on/off

This commit is contained in:
David Heinemeier Hansson
2026-05-06 12:12:26 +02:00
parent ca74b4d1c5
commit 4d11f8cc06
3 changed files with 25 additions and 10 deletions
+14 -6
View File
@@ -1,15 +1,10 @@
#!/bin/bash
# omarchy:summary=Adjust brightness on the most likely display device.
# omarchy:args=<step>
# omarchy:args=<step|off|on>
step="${1:-+5%}"
if omarchy-hyprland-monitor-focused-apple; then
omarchy-brightness-display-apple "$step"
exit
fi
# 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
@@ -19,6 +14,19 @@ 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
fi
# Current brightness percentage
current=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
+9 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# omarchy:summary=Adjust keyboard backlight brightness using available steps.
# omarchy:args=<up|down|cycle>
# omarchy:args=<up|down|cycle|off|restore>
direction="${1:-up}"
@@ -19,6 +19,14 @@ if [[ -z $device ]]; then
exit 1
fi
if [[ $direction == "off" ]]; then
brightnessctl -sd "$device" set 0 >/dev/null
exit 0
elif [[ $direction == "restore" ]]; then
brightnessctl -rd "$device" >/dev/null
exit 0
fi
# Get current and max brightness to determine step size.
max_brightness="$(brightnessctl -d "$device" max)"
current_brightness="$(brightnessctl -d "$device" get)"
+2 -3
View File
@@ -5,6 +5,5 @@
# omarchy:name=wake
# omarchy:examples=omarchy system wake
hyprctl dispatch dpms on >/dev/null 2>&1
brightnessctl -r >/dev/null 2>&1
brightnessctl -rd '*::kbd_backlight' >/dev/null 2>&1
omarchy-brightness-display on
omarchy-brightness-keyboard restore