Created
November 14, 2019 23:19
-
-
Save r0xsh/38a83a97e2ece98cb40b9c95d7826185 to your computer and use it in GitHub Desktop.
Switch between pulseaudio sinks
This file contains hidden or 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
| get_sinks() | |
| { | |
| pacmd list-sinks |\ | |
| grep -E 'index:|device.description' |\ | |
| sed -e 's/^ *//;s/ *$//' -e 's/^\t*//;s/ *$//' -e 's/^* //'|\ | |
| sed -r -e 's/index: ([0-9]+)/[\1] /g' -e 's/device.description = "(.*)"/\1/g' |\ | |
| sed -ze 's/] \n/] /g' | |
| } | |
| switch_sink_default() | |
| { | |
| pacmd set-default-sink $1 || echo failed | |
| } | |
| switch_sink_applications() | |
| { | |
| pacmd list-sink-inputs | | |
| awk '/index:/{print $2}' | | |
| xargs -r -I{} pacmd move-sink-input {} $1 || | |
| echo failed | |
| } | |
| switch_sink() | |
| { | |
| switch_sink_default "$@" | |
| switch_sink_applications "$@" | |
| } | |
| switch_gui() | |
| { | |
| sink=$(get_sinks | rofi -dmenu) | |
| switch_sink $(echo $sink | sed -re 's/^\[([0-9]+)\]/\1/' | cut -d' ' -f1 ); | |
| } | |
| switch_gui |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment