aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-06-19 14:35:33 +0200
committerInigoGutierrez <inigogf.95@gmail.com>2022-06-19 14:35:33 +0200
commit82456c27d0a00f0b61c6c30238fc54166cec6b55 (patch)
tree820f9e8b0aed9a66097ef1557ba9af8da1e8ebb5
parent09852a186ad884a6f7009a7fad727746c2af4197 (diff)
downloadscripts-82456c27d0a00f0b61c6c30238fc54166cec6b55.tar.gz
scripts-82456c27d0a00f0b61c6c30238fc54166cec6b55.zip
Created script to select audio sink.
-rwxr-xr-xi3blocks/i3vol.sh26
-rwxr-xr-xselectAudioSink.sh12
-rwxr-xr-xvol.sh4
3 files changed, 36 insertions, 6 deletions
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)"
diff --git a/selectAudioSink.sh b/selectAudioSink.sh
new file mode 100755
index 0000000..58bf9f6
--- /dev/null
+++ b/selectAudioSink.sh
@@ -0,0 +1,12 @@
+#!/bin/sh
+
+# selectAudioSink.sh
+#
+# Sets an audio sink.
+
+port="$(pactl list sinks |
+ sed -n '/Ports/,/Active Port/p' |
+ sed '/Ports/d;/Active/d;s/:.*$//;s/^\s*//' |
+ dmenu -c -bw 3 -i -l 10)"
+
+pactl set-sink-port alsa_output.pci-0000_00_1f.3.analog-stereo "$port"
diff --git a/vol.sh b/vol.sh
index 0ee7e35..180cfe6 100755
--- a/vol.sh
+++ b/vol.sh
@@ -1,5 +1,7 @@
#!/bin/sh
-sink="$(pactl list sinks | grep "^Sink " | cut -d'#' -f2 | tail -n 1)"
+
+sink="@DEFAULT_SINK@"
+
if [ "$1" = "mute" ]; then
pactl set-sink-mute "$sink" toggle
else