aboutsummaryrefslogtreecommitdiff
path: root/.togglesink.sh
diff options
context:
space:
mode:
Diffstat (limited to '.togglesink.sh')
-rw-r--r--.togglesink.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/.togglesink.sh b/.togglesink.sh
new file mode 100644
index 0000000..eee44c6
--- /dev/null
+++ b/.togglesink.sh
@@ -0,0 +1,21 @@
1#/usr/bin/env sh
2
3sinks=($(pactl list short sinks | awk '{print $2}'))
4current_sink=$(pactl get-default-sink)
5current_index=-1
6
7for i in "${!sinks[@]}"; do
8 if [[ "${sinks[$i]}" == "$current_sink" ]]; then
9 current_index=$i
10 break
11 fi
12done
13
14if [[ $current_index -eq -1 ]]; then
15 next_index=0
16else
17 next_index=$(( (current_index + 1) % ${#sinks[@]} ))
18fi
19
20pactl set-default-sink "${sinks[$next_index]}"
21notify-send "Switched to sink: ${sinks[$next_index]}"