From edf7067797ef10117c11079d6d08422f014fda13 Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Wed, 22 Apr 2026 13:04:30 +0200 Subject: [PATCH] Extract omarchy-swayosd-client So we don't have to manually compose it every time --- bin/omarchy-cmd-audio-switch | 9 ++------- bin/omarchy-cmd-mic-mute | 2 +- bin/omarchy-cmd-mic-mute-xps | 3 +-- bin/omarchy-swayosd-brightness | 3 +-- bin/omarchy-swayosd-client | 5 +++++ bin/omarchy-swayosd-kbd-brightness | 3 +-- bin/omarchy-toggle-touchpad | 1 - default/hypr/bindings/media.conf | 21 +++++++++------------ 8 files changed, 20 insertions(+), 27 deletions(-) create mode 100755 bin/omarchy-swayosd-client diff --git a/bin/omarchy-cmd-audio-switch b/bin/omarchy-cmd-audio-switch index de81cc3f..a0d7ef85 100755 --- a/bin/omarchy-cmd-audio-switch +++ b/bin/omarchy-cmd-audio-switch @@ -2,15 +2,11 @@ # Switch between audio outputs while preserving the mute status. By default mapped to Super + Mute. -focused_monitor=$(omarchy-hyprland-monitor-focused) - sinks=$(pactl -f json list sinks | jq '[.[] | select((.ports | length == 0) or ([.ports[]? | .availability != "not available"] | any))]') sinks_count=$(echo "$sinks" | jq '. | length') if (( sinks_count == 0 )); then - swayosd-client \ - --monitor "$focused_monitor" \ - --custom-message "No audio devices found" + omarchy-swayosd-client --custom-message "No audio devices found" exit 1 fi @@ -60,7 +56,6 @@ if [[ $next_sink_name != $current_sink_name ]]; then pactl set-default-sink "$next_sink_name" fi -swayosd-client \ - --monitor "$focused_monitor" \ +omarchy-swayosd-client \ --custom-message "$next_sink_description" \ --custom-icon "$next_sink_volume_icon" diff --git a/bin/omarchy-cmd-mic-mute b/bin/omarchy-cmd-mic-mute index 7f10fa94..a1a76cec 100755 --- a/bin/omarchy-cmd-mic-mute +++ b/bin/omarchy-cmd-mic-mute @@ -5,5 +5,5 @@ if omarchy-hw-match "XPS"; then omarchy-cmd-mic-mute-xps else - swayosd-client --monitor "$(omarchy-hyprland-monitor-focused)" --input-volume mute-toggle + omarchy-swayosd-client --input-volume mute-toggle fi diff --git a/bin/omarchy-cmd-mic-mute-xps b/bin/omarchy-cmd-mic-mute-xps index 8e7ca135..16b2da19 100755 --- a/bin/omarchy-cmd-mic-mute-xps +++ b/bin/omarchy-cmd-mic-mute-xps @@ -38,7 +38,6 @@ if [[ -e /sys/class/leds/platform::micmute/brightness ]]; then done fi -swayosd-client \ - --monitor "$(omarchy-hyprland-monitor-focused)" \ +omarchy-swayosd-client \ --custom-message "$osd_message" \ --custom-icon "$osd_icon" diff --git a/bin/omarchy-swayosd-brightness b/bin/omarchy-swayosd-brightness index 0dbe44d2..c65f52a6 100755 --- a/bin/omarchy-swayosd-brightness +++ b/bin/omarchy-swayosd-brightness @@ -8,8 +8,7 @@ percent="$1" progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')" [[ $progress == "0.00" ]] && progress="0.01" -swayosd-client \ - --monitor "$(omarchy-hyprland-monitor-focused)" \ +omarchy-swayosd-client \ --custom-icon display-brightness \ --custom-progress "$progress" \ --custom-progress-text "${percent}%" diff --git a/bin/omarchy-swayosd-client b/bin/omarchy-swayosd-client new file mode 100755 index 00000000..e05beb4f --- /dev/null +++ b/bin/omarchy-swayosd-client @@ -0,0 +1,5 @@ +#!/bin/bash + +# Wrapper for swayosd-client that targets the currently focused monitor. + +exec swayosd-client --monitor "$(omarchy-hyprland-monitor-focused)" "$@" diff --git a/bin/omarchy-swayosd-kbd-brightness b/bin/omarchy-swayosd-kbd-brightness index bf51d749..1925ae34 100755 --- a/bin/omarchy-swayosd-kbd-brightness +++ b/bin/omarchy-swayosd-kbd-brightness @@ -8,8 +8,7 @@ percent="$1" progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')" [[ $progress == "0.00" ]] && progress="0.01" -swayosd-client \ - --monitor "$(omarchy-hyprland-monitor-focused)" \ +omarchy-swayosd-client \ --custom-icon keyboard-brightness \ --custom-progress "$progress" \ --custom-progress-text "${percent}%" diff --git a/bin/omarchy-toggle-touchpad b/bin/omarchy-toggle-touchpad index fbbea79a..cc1ce7ba 100755 --- a/bin/omarchy-toggle-touchpad +++ b/bin/omarchy-toggle-touchpad @@ -1,7 +1,6 @@ #!/bin/bash STATE_CONF="$HOME/.local/state/omarchy/toggles/hypr/touchpad-disabled.conf" -osdclient="swayosd-client --monitor $(omarchy-hyprland-monitor-focused)" device="$(omarchy-hw-touchpad)" diff --git a/default/hypr/bindings/media.conf b/default/hypr/bindings/media.conf index c4f78b2c..c02872dc 100644 --- a/default/hypr/bindings/media.conf +++ b/default/hypr/bindings/media.conf @@ -1,10 +1,7 @@ -# Only display the OSD on the currently focused monitor -$osdclient = swayosd-client --monitor "$(omarchy-hyprland-monitor-focused)" - # Laptop multimedia keys for volume and LCD brightness (with OSD) -bindeld = ,XF86AudioRaiseVolume, Volume up, exec, $osdclient --output-volume raise -bindeld = ,XF86AudioLowerVolume, Volume down, exec, $osdclient --output-volume lower -bindeld = ,XF86AudioMute, Mute, exec, $osdclient --output-volume mute-toggle +bindeld = ,XF86AudioRaiseVolume, Volume up, exec, omarchy-swayosd-client --output-volume raise +bindeld = ,XF86AudioLowerVolume, Volume down, exec, omarchy-swayosd-client --output-volume lower +bindeld = ,XF86AudioMute, Mute, exec, omarchy-swayosd-client --output-volume mute-toggle bindeld = ,XF86AudioMicMute, Mute microphone, exec, omarchy-cmd-mic-mute bindeld = ,XF86MonBrightnessUp, Brightness up, exec, omarchy-brightness-display +5% bindeld = ,XF86MonBrightnessDown, Brightness down, exec, omarchy-brightness-display 5%- @@ -16,16 +13,16 @@ bindld = ,XF86TouchpadOn, Enable touchpad, exec, omarchy-toggle-touchpad on bindld = ,XF86TouchpadOff, Disable touchpad, exec, omarchy-toggle-touchpad off # 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, XF86AudioRaiseVolume, Volume up precise, exec, omarchy-swayosd-client --output-volume +1 +bindeld = ALT, XF86AudioLowerVolume, Volume down precise, exec, omarchy-swayosd-client --output-volume -1 bindeld = ALT, XF86MonBrightnessUp, Brightness up precise, exec, omarchy-brightness-display +1% bindeld = ALT, XF86MonBrightnessDown, Brightness down precise, exec, omarchy-brightness-display 1%- # Requires playerctl -bindld = , XF86AudioNext, Next track, exec, $osdclient --playerctl next -bindld = , XF86AudioPause, Pause, exec, $osdclient --playerctl play-pause -bindld = , XF86AudioPlay, Play, exec, $osdclient --playerctl play-pause -bindld = , XF86AudioPrev, Previous track, exec, $osdclient --playerctl previous +bindld = , XF86AudioNext, Next track, exec, omarchy-swayosd-client --playerctl next +bindld = , XF86AudioPause, Pause, exec, omarchy-swayosd-client --playerctl play-pause +bindld = , XF86AudioPlay, Play, exec, omarchy-swayosd-client --playerctl play-pause +bindld = , XF86AudioPrev, Previous track, exec, omarchy-swayosd-client --playerctl previous # Switch audio output with Super + Mute bindld = SUPER, XF86AudioMute, Switch audio output, exec, omarchy-cmd-audio-switch