From d884265d46d1cd0add1146c9f20a24c23def0c45 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Mon, 19 Jan 2026 17:53:19 -0400 Subject: [PATCH] Add keyboard brightness controls --- bin/omarchy-brightness-keyboard | 40 ++++++++++++++++++++++++++++++++ default/hypr/bindings/media.conf | 2 ++ 2 files changed, 42 insertions(+) create mode 100755 bin/omarchy-brightness-keyboard diff --git a/bin/omarchy-brightness-keyboard b/bin/omarchy-brightness-keyboard new file mode 100755 index 00000000..ea3a67b2 --- /dev/null +++ b/bin/omarchy-brightness-keyboard @@ -0,0 +1,40 @@ +#!/bin/bash + +# Adjust keyboard backlight brightness using available steps. +# Usage: omarchy-brightness-keyboard + +direction="${1:-up}" + +# Find keyboard backlight device (look for *kbd_backlight* pattern in leds class). +device="" +for candidate in /sys/class/leds/*kbd_backlight*; do + if [[ -e "$candidate" ]]; then + device="$(basename "$candidate")" + break + fi +done + +if [[ -z "$device" ]]; then + echo "No keyboard backlight device found" >&2 + exit 1 +fi + +# Get current and max brightness to determine step size. +max_brightness="$(brightnessctl -d "$device" max)" +current_brightness="$(brightnessctl -d "$device" get)" + +# Calculate step as one unit (keyboards typically have discrete levels like 0-3). +if [[ "$direction" == "up" ]]; then + new_brightness=$((current_brightness + 1)) + [[ $new_brightness -gt $max_brightness ]] && new_brightness=$max_brightness +else + new_brightness=$((current_brightness - 1)) + [[ $new_brightness -lt 0 ]] && new_brightness=0 +fi + +# Set the new brightness. +brightnessctl -d "$device" set "$new_brightness" >/dev/null + +# Use SwayOSD to display the new brightness setting. +percent=$((new_brightness * 100 / max_brightness)) +omarchy-swayosd-brightness "$percent" diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index 254a2ccc..38334119 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -8,6 +8,8 @@ bindeld = ,XF86AudioMute, Mute, exec, $osdclient --output-volume mute-toggle bindeld = ,XF86AudioMicMute, Mute microphone, exec, $osdclient --input-volume mute-toggle bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-brightness-display +5% bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-brightness-display 5%- +bindeld = ,XF86KbdBrightnessUp, Keyboard brightness up, exec, omarchy-brightness-keyboard up +bindeld = ,XF86KbdBrightnessDown, Keyboard brightness down, exec, omarchy-brightness-keyboard down # Precise 1% multimedia adjustments with Alt modifier bindeld = ALT, XF86AudioRaiseVolume, Volume up precise, exec, $osdclient --output-volume +1