sway_volume: update toggle for more than 2 sinks

This commit is contained in:
Konstantin Koslowski 2025-01-10 09:36:36 +01:00
parent ff9b5c93a1
commit bd21fbe4ca

View file

@ -14,8 +14,8 @@ function _get_default_sink() {
pactl info | grep "Default Sink" | cut -d ' ' -f 3 pactl info | grep "Default Sink" | cut -d ' ' -f 3
} }
function _get_sink_nick() { function _get_sink_desc() {
pactl -f json list sinks | jq -c ".[] | select(.name | contains(\"$1\")) | .properties.\"device.nick\"" | sed 's/"//g' pactl -f json list sinks | jq -c ".[] | select(.name | contains(\"$1\")) | .description" | sed 's/"//g'
} }
function notify() { function notify() {
@ -24,7 +24,7 @@ function notify() {
SOURCE_VOLUME=$(pactl list sources | grep "Name: $SOURCE" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//') SOURCE_VOLUME=$(pactl list sources | grep "Name: $SOURCE" -A 8 | grep -oE '[0-9]*%' | head -n 1 | sed 's/%//')
MUTE=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep 'Mute:' | cut -d " " -f 2) MUTE=$(pactl list sinks | grep "Name: $SINK" -A 8 | grep 'Mute:' | cut -d " " -f 2)
SOURCE_MUTE=$(pactl list sources | grep "Name: $SOURCE" -A 8 | grep 'Mute:' | cut -d " " -f 2) SOURCE_MUTE=$(pactl list sources | grep "Name: $SOURCE" -A 8 | grep 'Mute:' | cut -d " " -f 2)
NICK=$(_get_sink_nick $SINK) DESC=$(_get_sink_desc $SINK)
ICON=$ICON_PATH/audio-volume-high.svg ICON=$ICON_PATH/audio-volume-high.svg
SINK_ICON="" SINK_ICON=""
@ -43,11 +43,12 @@ function notify() {
fi fi
TITLE="${SINK_ICON} ${SINK_VOLUME}% / ${SOURCE_ICON} ${SOURCE_VOLUME}%" TITLE="${SINK_ICON} ${SINK_VOLUME}% / ${SOURCE_ICON} ${SOURCE_VOLUME}%"
# $NOTIFY_APP -i $ICON -a "Volume" "$TEXT" # $NOTIFY_APP -i $ICON -a "Volume" "$TEXT"
$NOTIFY_APP -i $ICON "$TITLE" "$NICK\n$(getProgressString 10 "$VOL1" "$VOL2" $SINK_VOLUME)" $NOTIFY_APP -i $ICON "$TITLE" "$DESC\n$(getProgressString 10 "$VOL1" "$VOL2" $SINK_VOLUME)"
} }
function _toggle_sink() { function _toggle_sink() {
sink_next=$(pactl list sinks | grep node\.name | grep -oE '"[a-zA-Z0-9_.-]*"' | grep -v $1 | sed 's/"//g' | sort -R) sink_next=$(pactl list sinks | grep node\.name | grep -oE '"[a-zA-Z0-9_.-]*"' | grep -v $1 | sed 's/"//g' | sort -R | head -n 1)
echo "$sink_next"
pactl set-default-sink $sink_next pactl set-default-sink $sink_next
} }