Last active
December 22, 2019 18:50
-
-
Save jrh-spg/c8be98c4f9bb01ecac894d676d2d00e4 to your computer and use it in GitHub Desktop.
Pulse Audio Sink Selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tempfile=$(tempfile 2>/dev/null) || tempfile=/tmp/test$$ | |
trap "rm -f $tempfile" 0 1 2 5 15 | |
INPUT=$(mktemp) | |
function get_all_sinks() { | |
pacmd list-sinks | grep -e 'name:' | cut -d: -f2 | cut -d\< -f2 | cut -d\> -f1 | |
} | |
function set_sink() { | |
pacmd set-default-sink ${choice} | |
} | |
availableSinks=$(get_all_sinks) | |
function sinkList() { | |
number=0 | |
for sink in $(get_all_sinks); do | |
printf "%s " $((number++)) ${sink} | |
done | |
} | |
function menu() { | |
dialog --clear \ | |
--backtitle "Select Pulse Audio Sink" \ | |
--stdout \ | |
--title "[ Sink Selector ]" \ | |
--menu "Select Pulse Audio Sink" \ | |
25 70 21 \ | |
$(sinkList) >${tempfile} | |
} | |
$(menu) | |
retval=${?} | |
choice=$(cat ${tempfile}) | |
case ${retval} in | |
0) | |
killall pulseaudio | |
dialog --clear \ | |
--title "Sinkerator" \ | |
--msgbox "Selected ${choice}" \ | |
5 40 | |
$(set_sink) | |
clear | |
;; | |
1) | |
dialog --clear \ | |
--title "Sinkerator" \ | |
--msgbox "Canceled!" 5 15 ;; | |
255) | |
dialog --clear \ | |
--title "Sinkerator" \ | |
--msgbox "ESC Pressed" 5 15 ;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment