From ddb8081eaae1570960fc63458428d036b366cdb8 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sat, 2 May 2026 11:20:22 +0200 Subject: [PATCH] Integrate Apple display brightness controls with the normal hotkeys And add Shift + Brightness to go min/max --- bin/omarchy-brightness-display | 5 ++++ bin/omarchy-brightness-display-apple | 27 ++++++++++++++++++---- bin/omarchy-hyprland-monitor-focused-apple | 5 ++++ default/hypr/bindings/media.conf | 2 ++ default/hypr/bindings/utilities.conf | 5 ---- 5 files changed, 35 insertions(+), 9 deletions(-) create mode 100755 bin/omarchy-hyprland-monitor-focused-apple diff --git a/bin/omarchy-brightness-display b/bin/omarchy-brightness-display index 7c421737..558a47de 100755 --- a/bin/omarchy-brightness-display +++ b/bin/omarchy-brightness-display @@ -5,6 +5,11 @@ 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 diff --git a/bin/omarchy-brightness-display-apple b/bin/omarchy-brightness-display-apple index 71b297ea..28c9e2ea 100755 --- a/bin/omarchy-brightness-display-apple +++ b/bin/omarchy-brightness-display-apple @@ -1,13 +1,32 @@ #!/bin/bash # omarchy:summary=Adjust the brightness on Apple Studio Displays and Apple XDR Displays using asdcontrol. -# omarchy:requires-sudo=true if (( $# == 0 )); then - echo "Adjust Apple Display Brightness by passing +5000 or -5000 (or any range from 0-60000)" + echo "Adjust Apple Display brightness by passing +5%, 5%-, or 100%" else - device="$(sudo asdcontrol --detect /dev/usb/hiddev* | grep ^/dev/usb/hiddev | cut -d: -f1)" - sudo asdcontrol "$device" -- "$1" >/dev/null + step="$1" + if [[ $step =~ ^([0-9]+)%-$ ]]; then + step="-${BASH_REMATCH[1]}%" + fi + + devices=() + for path in /dev/usb/hiddev* /dev/hiddev*; do + [[ -e $path ]] && devices+=("$path") + done + + if (( ${#devices[@]} == 0 )); then + echo "No Apple Display HID device found" + exit 1 + fi + + device="$(sudo asdcontrol --detect "${devices[@]}" | grep -E '^/dev/(usb/)?hiddev' | cut -d: -f1 | head -n1)" + if [[ -z $device ]]; then + echo "No Apple Display HID device found" + exit 1 + fi + + sudo asdcontrol "$device" -- "$step" >/dev/null value="$(sudo asdcontrol "$device" | awk -F= '/BRIGHTNESS=/{print $2+0}')" omarchy-swayosd-brightness "$(( value * 100 / 60000 ))" fi diff --git a/bin/omarchy-hyprland-monitor-focused-apple b/bin/omarchy-hyprland-monitor-focused-apple new file mode 100755 index 00000000..1593c828 --- /dev/null +++ b/bin/omarchy-hyprland-monitor-focused-apple @@ -0,0 +1,5 @@ +#!/bin/bash + +# omarchy:summary=Return success if the focused Hyprland monitor is an Apple display. + +hyprctl monitors -j | jq -e '.[] | select(.focused == true) | select(.make == "Apple Computer Inc" and (.model | test("StudioDisplay|ProDisplayXDR")))' >/dev/null diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index af1496de..d18f5aa5 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -5,6 +5,8 @@ bindeld = ,XF86AudioMute, Mute, exec, omarchy-swayosd-client --output-volume mut bindeld = ,XF86AudioMicMute, Mute microphone, exec, omarchy-audio-input-mute bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-brightness-display +5% bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-brightness-display 5%- +bindeld = SHIFT, XF86MonBrightnessUp, Brightness maximum, exec, omarchy-brightness-display 100% +bindeld = SHIFT, XF86MonBrightnessDown, Brightness minimum, exec, omarchy-brightness-display 1% bindeld = ,XF86KbdBrightnessUp, Keyboard brightness up, exec, omarchy-brightness-keyboard up bindeld = ,XF86KbdBrightnessDown, Keyboard brightness down, exec, omarchy-brightness-keyboard down bindld = ,XF86KbdLightOnOff, Keyboard backlight cycle, exec, omarchy-brightness-keyboard cycle diff --git a/default/hypr/bindings/utilities.conf b/default/hypr/bindings/utilities.conf index 97d9bcbd..bc912f0e 100644 --- a/default/hypr/bindings/utilities.conf +++ b/default/hypr/bindings/utilities.conf @@ -34,11 +34,6 @@ bindd = SUPER CTRL ALT, Delete, Toggle laptop display mirroring, exec, omarchy-h bindl = , switch:on:Lid Switch, exec, omarchy-hw-external-monitors && omarchy-hyprland-monitor-internal off bindl = , switch:off:Lid Switch, exec, omarchy-hyprland-monitor-internal on -# Control Apple Display brightness -bindd = CTRL, F1, Apple Display brightness down, exec, omarchy-brightness-display-apple -5000 -bindd = CTRL, F2, Apple Display brightness up, exec, omarchy-brightness-display-apple +5000 -bindd = SHIFT CTRL, F2, Apple Display full brightness, exec, omarchy-brightness-display-apple +60000 - # Captures bindd = , PRINT, Screenshot, exec, omarchy-capture-screenshot bindd = ALT, PRINT, Screenrecording, exec, omarchy-menu screenrecord