Add new display widget for the bar

This commit is contained in:
David Heinemeier Hansson
2026-05-17 17:29:52 +02:00
parent cf4935f964
commit 540aaf956d
10 changed files with 471 additions and 13 deletions
+2 -10
View File
@@ -21,21 +21,13 @@ runtime_dir="${XDG_RUNTIME_DIR:-/tmp}"
exec 9>"$runtime_dir/omarchy-brightness-display.lock"
flock -n 9 || exit 0
# 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
if omarchy-hyprland-monitor-focused-apple; then
omarchy-brightness-display-apple "$step"
exit
fi
device="$(omarchy-hw-display)" || exit 1
# Current brightness percentage
current=$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')
+1 -2
View File
@@ -29,6 +29,5 @@ else
fi
sudo asdcontrol "$device" -- "$step" >/dev/null
value="$(sudo asdcontrol "$device" | awk -F= '/BRIGHTNESS=/{print $2+0}')"
omarchy-osd -i brightness -p "$(( value * 100 / 60000 ))"
omarchy-osd -i brightness -p "$(omarchy-brightness-display-apple-get)"
fi
+20
View File
@@ -0,0 +1,20 @@
#!/bin/bash
# omarchy:summary=Get Apple Studio Display or XDR Display brightness using asdcontrol.
# omarchy:examples=omarchy brightness display apple get | omarchy-brightness-display-apple-get
device="$(sudo asdcontrol --detect /dev/usb/hiddev* /dev/hiddev* 2>/dev/null | awk -F: '/^\/dev\/(usb\/)?hiddev/{ print $1; exit }')"
if [[ -z $device ]]; then
echo "No Apple Display HID device found" >&2
exit 1
fi
sudo asdcontrol "$device" 2>/dev/null | awk -F= '
/BRIGHTNESS=/ {
print int($2 * 100 / 60000)
found = 1
}
END { exit !found }
'
+10
View File
@@ -0,0 +1,10 @@
#!/bin/bash
# omarchy:summary=Get brightness for the most likely display device.
# omarchy:examples=omarchy-brightness-display-get
if omarchy-hyprland-monitor-focused-apple; then
omarchy-brightness-display-apple-get
else
brightnessctl -d "$(omarchy-hw-display)" -m 2>/dev/null | awk -F, '{ gsub("%", "", $4); print $4; found=1 } END{ exit !found }'
fi
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
# omarchy:summary=Print the most likely display backlight device.
# omarchy:examples=omarchy-hw-display
# 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
if [[ -n $device ]]; then
printf '%s\n' "$device"
else
exit 1
fi
+6
View File
@@ -0,0 +1,6 @@
#!/bin/bash
# omarchy:summary=Get focused Hyprland monitor scaling
# omarchy:examples=omarchy-hyprland-monitor-scaling-get
hyprctl monitors -j | jq -r '.[] | select(.focused == true) | .scale'