Integrate swaybg and swayosd into the new shell

This commit is contained in:
David Heinemeier Hansson
2026-05-16 20:34:09 +02:00
parent 83e7f41308
commit 1eab0cffc9
48 changed files with 665 additions and 353 deletions
+2 -1
View File
@@ -27,6 +27,7 @@ declare -A BINARY_TO_KEY
declare -A GROUP_DESCRIPTIONS
GROUP_DESCRIPTIONS[ac]="AC power detection"
GROUP_DESCRIPTIONS[audio]="Audio input and output controls"
GROUP_DESCRIPTIONS[battery]="Battery status helpers"
GROUP_DESCRIPTIONS[branch]="Omarchy git branch management"
GROUP_DESCRIPTIONS[branding]="About and screensaver branding"
@@ -51,6 +52,7 @@ GROUP_DESCRIPTIONS[menu]="Omarchy menu commands"
GROUP_DESCRIPTIONS[migrate]="Migration runner"
GROUP_DESCRIPTIONS[notification]="Notification helpers"
GROUP_DESCRIPTIONS[npx]="NPX package wrappers"
GROUP_DESCRIPTIONS[osd]="On-screen display status helpers"
GROUP_DESCRIPTIONS[pkg]="Package management helpers"
GROUP_DESCRIPTIONS[plymouth]="Plymouth boot theme management"
GROUP_DESCRIPTIONS[powerprofiles]="Power profile management"
@@ -64,7 +66,6 @@ GROUP_DESCRIPTIONS[screensaver]="Screensaver branding and animation"
GROUP_DESCRIPTIONS[snapshot]="System snapshots"
GROUP_DESCRIPTIONS[style]="Global UI style controls"
GROUP_DESCRIPTIONS[sudo]="Sudo configuration helpers"
GROUP_DESCRIPTIONS[swayosd]="SwayOSD status display helpers"
GROUP_DESCRIPTIONS[system]="Reboot, shutdown, logout, and lock"
GROUP_DESCRIPTIONS[theme]="Theme management"
GROUP_DESCRIPTIONS[toggle]="Toggle Omarchy features"
+5 -13
View File
@@ -4,18 +4,10 @@
wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle >/dev/null
if pactl get-source-mute @DEFAULT_SOURCE@ | rg -q 'yes'; then
led=on
osd_message='Microphone muted'
osd_icon='microphone-sensitivity-muted-symbolic'
if wpctl get-volume @DEFAULT_AUDIO_SOURCE@ | grep -q MUTED; then
omarchy-brightness-keyboard-mute on
omarchy-osd -i microphone-muted -m "Microphone muted"
else
led=off
osd_message='Microphone on'
osd_icon='audio-input-microphone-symbolic'
omarchy-brightness-keyboard-mute off
omarchy-osd -i microphone -m "Microphone on"
fi
omarchy-brightness-keyboard-mute "$led"
omarchy-swayosd-client \
--custom-message "$osd_message" \
--custom-icon "$osd_icon"
+13 -31
View File
@@ -2,16 +2,18 @@
# omarchy:summary=Switch between audio outputs while preserving the mute status. By default mapped to Super + Mute.
set -euo pipefail
sinks=$(pactl -f json list sinks | jq '[.[] | select((.ports | length == 0) or ([.ports[]? | .availability != "not available"] | any))]')
sinks_count=$(echo "$sinks" | jq '. | length')
sinks_count=$(jq 'length' <<<"$sinks")
if (( sinks_count == 0 )); then
omarchy-swayosd-client --custom-message "No audio devices found"
omarchy-osd -m "No audio devices found"
exit 1
fi
current_sink_name=$(pactl get-default-sink)
current_sink_index=$(echo "$sinks" | jq -r --arg name "$current_sink_name" 'map(.name) | index($name)')
current_sink_index=$(jq -r --arg name "$current_sink_name" 'map(.name) | index($name)' <<<"$sinks")
if [[ $current_sink_index != "null" ]]; then
next_sink_index=$(((current_sink_index + 1) % sinks_count))
@@ -19,28 +21,13 @@ else
next_sink_index=0
fi
next_sink=$(echo "$sinks" | jq -r ".[$next_sink_index]")
next_sink_name=$(echo "$next_sink" | jq -r '.name')
next_sink=$(jq -c ".[$next_sink_index]" <<<"$sinks")
next_sink_name=$(jq -r '.name' <<<"$next_sink")
next_sink_description=$(jq -r '.description // .properties."device.description" // .name' <<<"$next_sink")
next_sink_volume=$(jq -r '.volume | to_entries[0].value.value_percent | sub("%"; "") | tonumber' <<<"$next_sink")
next_sink_is_muted=$(jq -r '.mute' <<<"$next_sink")
next_sink_description=$(echo "$next_sink" | jq -r '.description')
if [[ $next_sink_description == "(null)" ]] || [[ $next_sink_description == "null" ]] || [[ -z $next_sink_description ]]; then
# For Bluetooth devices, the friendly name is on the Device entry (device.id), not the Sink entry (object.id)
device_id=$(echo "$next_sink" | jq -r '.properties."device.id"')
if [[ $device_id != "null" ]] && [[ -n $device_id ]]; then
next_sink_description=$(wpctl status | grep -E "^\s*│?\s+${device_id}\." | sed -E 's/^.*[0-9]+\.\s+//' | sed -E 's/\s+\[.*$//')
fi
# Fall back to object.id lookup if device.id didn't yield a result
if [[ -z $next_sink_description ]]; then
sink_id=$(echo "$next_sink" | jq -r '.properties."object.id"')
next_sink_description=$(wpctl status | grep -E "\s+\*?\s+${sink_id}\." | sed -E 's/^.*[0-9]+\.\s+//' | sed -E 's/\s+\[.*$//')
fi
fi
next_sink_volume=$(echo "$next_sink" | jq -r \
'.volume | to_entries[0].value.value_percent | sub("%"; "")')
next_sink_is_muted=$(echo "$next_sink" | jq -r '.mute')
if [[ $next_sink_is_muted = "true" ]] || (( next_sink_volume == 0 )); then
if [[ $next_sink_is_muted == "true" ]] || (( next_sink_volume == 0 )); then
icon_state="muted"
elif (( next_sink_volume <= 33 )); then
icon_state="low"
@@ -50,13 +37,8 @@ else
icon_state="high"
fi
next_sink_volume_icon="sink-volume-${icon_state}-symbolic"
if [[ $next_sink_name != $current_sink_name ]]; then
next_sink_wpid=$(echo "$next_sink" | jq -r '.properties."object.id"')
wpctl set-default "$next_sink_wpid"
pactl set-default-sink "$next_sink_name"
fi
omarchy-swayosd-client \
--custom-message "$next_sink_description" \
--custom-icon "$next_sink_volume_icon"
omarchy-osd -i "volume-${icon_state}" -m "$next_sink_description"
+63
View File
@@ -0,0 +1,63 @@
#!/bin/bash
# omarchy:summary=Adjust output volume and show the Omarchy OSD
# omarchy:args=<raise|lower|mute-toggle|+N|-N>
# omarchy:examples=omarchy audio output volume raise | omarchy audio output volume lower | omarchy audio output volume mute-toggle | omarchy audio output volume +1
set -euo pipefail
action="${1:-}"
if [[ -z $action ]]; then
echo "Usage: omarchy-audio-output-volume <raise|lower|mute-toggle|+N|-N>"
exit 1
fi
volume_state() {
wpctl get-volume @DEFAULT_AUDIO_SINK@
}
volume_percent() {
volume_state | awk '{ for (i=1; i<=NF; i++) if ($i ~ /^[0-9.]+$/) print int($i * 100) }'
}
volume_muted() {
volume_state | grep -q MUTED
}
case "$action" in
raise) action="+5" ;;
lower) action="-5" ;;
esac
if [[ $action == "mute-toggle" ]]; then
runtime_dir="${XDG_RUNTIME_DIR:-/tmp}"
debounce_file="$runtime_dir/omarchy-audio-output-volume-mute-toggle.last"
now=$(date +%s%3N)
last=0
[[ -r $debounce_file ]] && read -r last < "$debounce_file" || true
if (( now - last < 250 )); then
exit 0
fi
printf '%s\n' "$now" > "$debounce_file"
wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle >/dev/null
elif [[ $action == +* ]]; then
step="${action#+}"
wpctl set-volume -l 1.0 @DEFAULT_AUDIO_SINK@ "${step}%+"
elif [[ $action == -* ]]; then
step="${action#-}"
wpctl set-volume @DEFAULT_AUDIO_SINK@ "${step}%-"
else
echo "Unknown volume action: $action"
exit 1
fi
percent=$(volume_percent)
if volume_muted || (( percent == 0 )); then
icon="volume-muted"
else
icon="volume-high"
fi
omarchy-osd -i "$icon" -p "$percent"
+28
View File
@@ -0,0 +1,28 @@
#!/bin/bash
# omarchy:summary=Control media playback and show the Omarchy OSD
# omarchy:args=<next|previous|play-pause|play|pause>
# omarchy:examples=omarchy audio player next | omarchy audio player play-pause
set -euo pipefail
action="${1:-play-pause}"
playerctl "$action" >/dev/null 2>&1 || true
sleep 0.05
message=$(playerctl metadata --format '{{title}}' 2>/dev/null || true)
if [[ -z $message ]]; then
message=$(playerctl metadata --format '{{playerName}}' 2>/dev/null || true)
fi
if [[ -z $message ]]; then
case "$action" in
next) message="Next track" ;;
previous) message="Previous track" ;;
play) message="Playing" ;;
pause) message="Paused" ;;
*) message="Play/pause" ;;
esac
fi
omarchy-osd -i media -m "$message"
+3 -3
View File
@@ -17,7 +17,7 @@ fi
runtime_dir="${XDG_RUNTIME_DIR:-/tmp}"
# Drop overlapping brightness key events so concurrent invocations do not race.
# Hardware key repeat present on some devices can otherwise glitch SwayOSD rendering.
# Hardware key repeat present on some devices can otherwise glitch OSD rendering.
exec 9>"$runtime_dir/omarchy-brightness-display.lock"
flock -n 9 || exit 0
@@ -64,5 +64,5 @@ fi
# Set the actual brightness of the display device.
brightnessctl -d "$device" set "$step" >/dev/null
# Use SwayOSD to display the new brightness setting.
omarchy-swayosd-brightness "$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')"
# Use the OSD to display the new brightness setting.
omarchy-osd -i brightness -p "$(brightnessctl -d "$device" -m | cut -d',' -f4 | tr -d '%')"
+1 -1
View File
@@ -30,5 +30,5 @@ else
sudo asdcontrol "$device" -- "$step" >/dev/null
value="$(sudo asdcontrol "$device" | awk -F= '/BRIGHTNESS=/{print $2+0}')"
omarchy-swayosd-brightness "$(( value * 100 / 60000 ))"
omarchy-osd -i brightness -p "$(( value * 100 / 60000 ))"
fi
+1 -4
View File
@@ -49,7 +49,4 @@ 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-kbd-brightness "$percent"
omarchy-osd -i keyboard -p "$(( new_brightness * 100 / max_brightness ))"
-1
View File
@@ -17,7 +17,6 @@ if [[ -f $FIRST_RUN_MODE ]]; then
bash "$OMARCHY_PATH/install/first-run/dns-resolver.sh"
bash "$OMARCHY_PATH/install/first-run/gnome-theme.sh"
bash "$OMARCHY_PATH/install/first-run/gdk-scale.sh"
bash "$OMARCHY_PATH/install/first-run/swayosd.sh"
bash "$OMARCHY_PATH/install/first-run/gtk-primary-paste.sh"
bash "$OMARCHY_PATH/install/first-run/elephant.sh"
omarchy-hook-install post-update "$OMARCHY_PATH/install/first-run/install-voxtype.hook"
+1 -2
View File
@@ -27,7 +27,6 @@ if [[ -n $font_name ]]; then
fi
sed -i "s/font_family = .*/font_family = $font_name/g" ~/.config/hypr/hyprlock.conf
sed -i "s/font-family: .*/font-family: '$font_name';/g" ~/.config/swayosd/style.css
# fontconfig is the canonical source of truth — the omarchy shell, Qt
# apps, and anything else that resolves "monospace" all read from here.
@@ -36,7 +35,7 @@ if [[ -n $font_name ]]; then
-v "$font_name" \
~/.config/fontconfig/fonts.conf
omarchy-restart-swayosd
omarchy-restart-shell
if pgrep -x ghostty; then
notify-send -a omarchy-action -u low " You must restart Ghostty to see font change"
+37
View File
@@ -0,0 +1,37 @@
#!/bin/bash
# omarchy:summary=Show the Omarchy Quickshell on-screen display
# omarchy:args=[-i|--icon <icon>] [-m|--message <text>] [-p|--progress <0-100>]
# omarchy:examples=omarchy osd -i brightness -p 50 | omarchy osd -m "Hello"
set -euo pipefail
icon=""
message=""
progress=""
progress_text=""
max="100"
while (($#)); do
case $1 in
-i|--icon) icon="${2:-}"; shift 2 ;;
-m|--message) message="${2:-}"; shift 2 ;;
-p|--progress) progress="${2:-}"; shift 2 ;;
-h|--help) omarchy osd --help; exit 0 ;;
*) echo "Unknown OSD option: $1" >&2; exit 1 ;;
esac
done
if [[ -n $progress ]]; then
progress_text="${progress}%"
fi
payload=$(jq -cn \
--arg icon "$icon" \
--arg message "$message" \
--arg value "$progress" \
--arg progressText "$progress_text" \
--arg max "$max" \
'{icon:$icon,message:$message,value:$value,progressText:$progressText,max:$max}')
omarchy-shell-ipc osd show "$payload" >/dev/null 2>&1 || true
-7
View File
@@ -1,7 +0,0 @@
#!/bin/bash
# omarchy:summary=Overwrite the user configs for swayosd (controls on-screen feedback for changing volume/songs etc) with the Omarchy defaults and restart the service.
omarchy-refresh-config swayosd/config.toml
omarchy-refresh-config swayosd/style.css
omarchy-restart-swayosd
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
# omarchy:summary=Restart the SwayOSD server
systemctl --user daemon-reload
systemctl --user stop swayosd-server.service || true
pkill -x swayosd-server || true
systemctl --user reset-failed swayosd-server.service || true
systemctl --user enable --now swayosd-server.service
+1 -1
View File
@@ -59,4 +59,4 @@ else
} 9>"$lockfile"
fi
exec quickshell ipc -p "$SHELL_DIR" call "$@"
exec quickshell ipc -p "$SHELL_DIR" call -- "$@"
-15
View File
@@ -1,15 +0,0 @@
#!/bin/bash
# omarchy:summary=Display brightness level using SwayOSD on the current monitor.
# omarchy:args=<0-100>
# omarchy:examples=omarchy swayosd brightness 0 | omarchy swayosd brightness 50 | omarchy swayosd brightness 100
percent="$1"
progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')"
[[ $progress == "0.00" ]] && progress="0.01"
omarchy-swayosd-client \
--custom-icon display-brightness-symbolic \
--custom-progress "$progress" \
--custom-progress-text "$(printf '%3d%%' "$percent")"
-6
View File
@@ -1,6 +0,0 @@
#!/bin/bash
# omarchy:summary=Wrapper for swayosd-client that targets the currently focused monitor.
# omarchy:args=<swayosd-client-args...>
exec swayosd-client --monitor "$(omarchy-hyprland-monitor-focused)" "$@"
-15
View File
@@ -1,15 +0,0 @@
#!/bin/bash
# omarchy:summary=Display keyboard brightness level using SwayOSD on the current monitor.
# omarchy:args=<0-100>
# omarchy:examples=omarchy swayosd kbd brightness 0 | omarchy swayosd kbd brightness 50 | omarchy swayosd kbd brightness 100
percent="$1"
progress="$(awk -v p="$percent" 'BEGIN{printf "%.2f", p/100}')"
[[ $progress == "0.00" ]] && progress="0.01"
omarchy-swayosd-client \
--custom-icon keyboard-brightness-symbolic \
--custom-progress "$progress" \
--custom-progress-text "${percent}%"
-4
View File
@@ -19,7 +19,3 @@ fi
# Create symlink to the new background
ln -nsf "$BACKGROUND" "$CURRENT_BACKGROUND_LINK"
# Kill existing swaybg and start new one
pkill -x swaybg
setsid uwsm-app -- swaybg -i "$CURRENT_BACKGROUND_LINK" -m fill >/dev/null 2>&1 &
+1 -1
View File
@@ -59,7 +59,7 @@ mv "$NEXT_THEME_PATH" "$CURRENT_THEME_PATH"
echo "$THEME_NAME" >"$HOME/.config/omarchy/current/theme.name"
post_theme_commands=(
omarchy-restart-swayosd
omarchy-restart-shell
omarchy-restart-terminal
omarchy-restart-hyprctl
omarchy-restart-btop
+2 -2
View File
@@ -15,14 +15,14 @@ fi
enable() {
hyprctl eval "hl.device({ name = \"$device\", enabled = true })" >/dev/null
rm -f "$STATE_FILE"
omarchy-swayosd-client --custom-icon input-touchpad-symbolic --custom-message "Touchpad enabled"
omarchy-osd -i touchpad -m "Touchpad enabled"
}
disable() {
hyprctl eval "hl.device({ name = \"$device\", enabled = false })" >/dev/null
mkdir -p "$(dirname "$STATE_FILE")"
printf 'hl.device({ name = "%s", enabled = false })\n' "$device" >"$STATE_FILE"
omarchy-swayosd-client --custom-icon touchpad-disabled-symbolic --custom-message "Touchpad disabled"
omarchy-osd -i touchpad -m "Touchpad disabled"
}
case "${1:-toggle}" in
+2 -2
View File
@@ -15,14 +15,14 @@ fi
enable() {
hyprctl eval "hl.device({ name = \"$device\", enabled = true })" >/dev/null
rm -f "$STATE_FILE"
omarchy-swayosd-client --custom-icon device-support-touch-symbolic --custom-message "Touchscreen enabled"
omarchy-osd -i touch -m "Touchscreen enabled"
}
disable() {
hyprctl eval "hl.device({ name = \"$device\", enabled = false })" >/dev/null
mkdir -p "$(dirname "$STATE_FILE")"
printf 'hl.device({ name = "%s", enabled = false })\n' "$device" >"$STATE_FILE"
omarchy-swayosd-client --custom-icon touch-disabled-symbolic --custom-message "Touchscreen disabled"
omarchy-osd -i touch -m "Touchscreen disabled"
}
case "${1:-toggle}" in