From 4d11f8cc06505e8d5503997a6db593c801dab406 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 6 May 2026 12:12:26 +0200 Subject: [PATCH] Extract turning brightness devices on/off --- bin/omarchy-brightness-display | 20 ++++++++++++++------ bin/omarchy-brightness-keyboard | 10 +++++++++- bin/omarchy-system-wake | 5 ++--- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/bin/omarchy-brightness-display b/bin/omarchy-brightness-display index 558a47de..8f79443f 100755 --- a/bin/omarchy-brightness-display +++ b/bin/omarchy-brightness-display @@ -1,15 +1,10 @@ #!/bin/bash # omarchy:summary=Adjust brightness on the most likely display device. -# omarchy:args= +# omarchy:args= 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 '%') diff --git a/bin/omarchy-brightness-keyboard b/bin/omarchy-brightness-keyboard index f161da47..7e5febe6 100755 --- a/bin/omarchy-brightness-keyboard +++ b/bin/omarchy-brightness-keyboard @@ -1,7 +1,7 @@ #!/bin/bash # omarchy:summary=Adjust keyboard backlight brightness using available steps. -# omarchy:args= +# omarchy:args= 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)" diff --git a/bin/omarchy-system-wake b/bin/omarchy-system-wake index df3df739..e5b90389 100755 --- a/bin/omarchy-system-wake +++ b/bin/omarchy-system-wake @@ -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