From 82456c27d0a00f0b61c6c30238fc54166cec6b55 Mon Sep 17 00:00:00 2001 From: InigoGutierrez Date: Sun, 19 Jun 2022 14:35:33 +0200 Subject: Created script to select audio sink. --- i3blocks/i3vol.sh | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'i3blocks') diff --git a/i3blocks/i3vol.sh b/i3blocks/i3vol.sh index c42eafb..0abf471 100755 --- a/i3blocks/i3vol.sh +++ b/i3blocks/i3vol.sh @@ -1,13 +1,29 @@ #!/bin/sh case $BLOCK_BUTTON in - 1) i3-msg "exec urxvt -e alsamixer" >/dev/null ;; - 3) pgrep -x dunst >/dev/null && notify-send -h string:x-canonical-private-synchronous:i3volHint -t 2000 "Click for alsamixer" ;; + 1) i3-msg 'exec urxvt -e alsamixer' >/dev/null ;; + 3) pgrep -x dunst >/dev/null && + notify-send -h string:x-canonical-private-synchronous:i3volHint -t 2000 'Click for alsamixer' ;; esac -vol=$(pactl list sinks | grep "Volume: f" | tail -n 1 | awk '{print $5}') -mute=$(pactl list sinks | grep "Mute:" | cut -d' ' -f2 | tail -n 1) -if [ "$mute" = "no" ]; then +sink="$(pactl list sinks short | + grep 'RUNNING' | + cut -f2)" + +vol="$(pactl list sinks | + grep -e 'Name' -e 'Volume: f' | + grep -A 1 "$sink" | + tail -n 1 | + awk '{print $5}' | + sed 's/%.*$/%/')" + +mute="$(pactl list sinks | + grep -e 'Name' -e 'Mute:' | + grep -A 1 "$sink" | + tail -n 1 | + cut -d' ' -f2)" + +if [ "$mute" = 'no' ]; then echo "🔊 $vol" else echo "🔇($vol)" -- cgit v1.2.1