diff options
Diffstat (limited to '.togglesink.sh')
| -rw-r--r-- | .togglesink.sh | 21 |
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 | |||
| 3 | sinks=($(pactl list short sinks | awk '{print $2}')) | ||
| 4 | current_sink=$(pactl get-default-sink) | ||
| 5 | current_index=-1 | ||
| 6 | |||
| 7 | for i in "${!sinks[@]}"; do | ||
| 8 | if [[ "${sinks[$i]}" == "$current_sink" ]]; then | ||
| 9 | current_index=$i | ||
| 10 | break | ||
| 11 | fi | ||
| 12 | done | ||
| 13 | |||
| 14 | if [[ $current_index -eq -1 ]]; then | ||
| 15 | next_index=0 | ||
| 16 | else | ||
| 17 | next_index=$(( (current_index + 1) % ${#sinks[@]} )) | ||
| 18 | fi | ||
| 19 | |||
| 20 | pactl set-default-sink "${sinks[$next_index]}" | ||
| 21 | notify-send "Switched to sink: ${sinks[$next_index]}" | ||
