Support single-key keyboard backlight cycling (#4672)

* Support single-key keyboard backlight cycling (like Asus F4) and add keyboard specific OSD icon

* We don't need an alias

---------

Co-authored-by: Ryan Latimer <ryan@example.com>
Co-authored-by: David Heinemeier Hansson <david@hey.com>
This commit is contained in:
Ryan Latimer
2026-02-20 19:37:55 +01:00
committed by GitHub
co-authored by Ryan Latimer David Heinemeier Hansson
parent e99afc98f8
commit db3ba3501a
3 changed files with 21 additions and 3 deletions
+5 -3
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# Adjust keyboard backlight brightness using available steps.
# Usage: omarchy-brightness-keyboard <up|down>
# Usage: omarchy-brightness-keyboard <up|down|cycle>
direction="${1:-up}"
@@ -24,7 +24,9 @@ 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
if [[ "$direction" == "cycle" ]]; then
new_brightness=$(( (current_brightness + 1) % (max_brightness + 1) ))
elif [[ "$direction" == "up" ]]; then
new_brightness=$((current_brightness + 1))
[[ $new_brightness -gt $max_brightness ]] && new_brightness=$max_brightness
else
@@ -37,4 +39,4 @@ 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"
omarchy-swayosd-kbd-brightness "$percent"
+15
View File
@@ -0,0 +1,15 @@
#!/bin/bash
# Display keyboard brightness level using SwayOSD on the current monitor.
# Usage: omarchy-swayosd-kbd-brightness <percent>
percent="$1"
progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')"
[[ "$progress" == "0.00" ]] && progress="0.01"
swayosd-client \
--monitor "$(hyprctl monitors -j | jq -r '.[]|select(.focused==true).name')" \
--custom-icon keyboard-brightness \
--custom-progress "$progress" \
--custom-progress-text "${percent}%"
+1
View File
@@ -10,6 +10,7 @@ bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-brightness-display
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
bindld = ,XF86KbdLightOnOff, Keyboard backlight cycle, exec, omarchy-brightness-keyboard cycle
# Precise 1% multimedia adjustments with Alt modifier
bindeld = ALT, XF86AudioRaiseVolume, Volume up precise, exec, $osdclient --output-volume +1