From 291786d36adca079fa46aad4dcee1e62f1538797 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 14 Jan 2026 16:37:22 -0500 Subject: [PATCH] Set brightness in a more broadly compatible way Fixes brightness setting on the Asus G14 --- bin/omarchy-cmd-brightness | 29 +++++++++++++++++++++++++++++ default/hypr/bindings/media.conf | 8 ++++---- 2 files changed, 33 insertions(+), 4 deletions(-) create mode 100755 bin/omarchy-cmd-brightness diff --git a/bin/omarchy-cmd-brightness b/bin/omarchy-cmd-brightness new file mode 100755 index 00000000..adcdacab --- /dev/null +++ b/bin/omarchy-cmd-brightness @@ -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}%" diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index efedbb72..fe302524 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -6,14 +6,14 @@ bindeld = ,XF86AudioRaiseVolume, Volume up, exec, $osdclient --output-volume rai bindeld = ,XF86AudioLowerVolume, Volume down, exec, $osdclient --output-volume lower bindeld = ,XF86AudioMute, Mute, exec, $osdclient --output-volume mute-toggle bindeld = ,XF86AudioMicMute, Mute microphone, exec, $osdclient --input-volume mute-toggle -bindeld = ,XF86MonBrightnessUp, Brightness up, exec, $osdclient --brightness raise -bindeld = ,XF86MonBrightnessDown, Brightness down, exec, $osdclient --brightness lower +bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-cmd-brightness +5% +bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-cmd-brightness 5%- # Precise 1% multimedia adjustments with Alt modifier bindeld = ALT, XF86AudioRaiseVolume, Volume up precise, exec, $osdclient --output-volume +1 bindeld = ALT, XF86AudioLowerVolume, Volume down precise, exec, $osdclient --output-volume -1 -bindeld = ALT, XF86MonBrightnessUp, Brightness up precise, exec, $osdclient --brightness +1 -bindeld = ALT, XF86MonBrightnessDown, Brightness down precise, exec, $osdclient --brightness -1 +bindeld = ALT, XF86MonBrightnessUp, Brightness up precise, exec, omarchy-cmd-brightness +1% +bindeld = ALT, XF86MonBrightnessDown, Brightness down precise, exec, omarchy-cmd-brightness 1%- # Requires playerctl bindld = , XF86AudioNext, Next track, exec, $osdclient --playerctl next