From 45be1fbdd733feae723d81c31cd61ac115312767 Mon Sep 17 00:00:00 2001 From: ltadeu6 Date: Wed, 1 Apr 2026 10:01:10 -0300 Subject: [PATCH] change audio output --- waybar/config | 1 + waybar/switch_sink.sh | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) create mode 100755 waybar/switch_sink.sh diff --git a/waybar/config b/waybar/config index 794b0d0..8623623 100644 --- a/waybar/config +++ b/waybar/config @@ -127,6 +127,7 @@ }, "scroll-step": 10, "on-click": "pavucontrol", + "on-click-right": "./switch_sink.sh", "ignored-sinks": ["Easy Effects Sink"], "tooltip-format": "{icon} {volume}" }, diff --git a/waybar/switch_sink.sh b/waybar/switch_sink.sh new file mode 100755 index 0000000..996de96 --- /dev/null +++ b/waybar/switch_sink.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env sh + +# Cycle default sink and move existing inputs. +if ! command -v pactl >/dev/null 2>&1; then + exit 1 +fi + +current="$(pactl get-default-sink 2>/dev/null)" +[ -z "$current" ] && exit 1 + +sinks="$(pactl list short sinks | awk '{print $2}')" +[ -z "$sinks" ] && exit 1 + +next="" +found=0 +for s in $sinks; do + if [ "$found" -eq 1 ]; then + next="$s" + break + fi + if [ "$s" = "$current" ]; then + found=1 + fi +done + +# If current is last or not found, wrap to first. +if [ -z "$next" ]; then + next="$(printf '%s\n' "$sinks" | head -n 1)" +fi + +pactl set-default-sink "$next" || exit 1 + +# Move existing audio streams to the new sink. +for input in $(pactl list short sink-inputs | awk '{print $1}'); do + pactl move-sink-input "$input" "$next" >/dev/null 2>&1 || true +done