aboutsummaryrefslogtreecommitdiff
path: root/cycle_pa_sinks
blob: aa48895138f9c5ac1fe95b3b61f63f8138dec852 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#!/bin/sh
#
# Cycle between the current PulseAudio sinks.
# Based on https://askubuntu.com/a/740002
#
# Usage: ./cycle_pa_sinks
################################################################################

new_sink=$(pacmd list-sinks | awk '/index/{print; i=1} i&&/device.product.name/{print; i=0}' | tee /dev/stdout | grep -m1 -A3 "* index"  | tail -2)
new_sink_idx=$(echo "$new_sink" | head -n1 | cut -c12-)
new_sink_name=$(echo "$new_sink" | tail -n1 | cut -f2 -d'"')

msg="Setting default sink to: #$new_sink_idx ($new_sink_name)"
if [ -t 0 ]; then
    echo "$msg"
else
    notify-send -u low -t 2000 "$msg"
fi
pacmd set-default-sink $new_sink_idx