Last active
April 16, 2024 09:25
-
-
Save Leenuus/b3c9dd7926f7526eb641b05791706481 to your computer and use it in GitHub Desktop.
Use rofi/fzf to switch between audio devices
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 | |
# NOTE: | |
# make sure disable two modules listed below | |
# module-stream-restore | |
# module-restore_device | |
# in ~/.config/pulse/default.pa | |
# read this post | |
# https://askubuntu.com/a/690748 | |
while [ "$#" -gt 0 ];do | |
case "$1" in | |
-g | --gui ) gui=1;; | |
*) ;; | |
esac | |
shift | |
done | |
# shellcheck disable=SC2016 | |
awk_program=' | |
/index:/ { | |
split($0, a, ": ") | |
} | |
/name:/ && $0 !~ /HDMI/ { | |
split($0, b, ": ") | |
printf("%s %s\n", a[2], b[2]) | |
} | |
' | |
main() { | |
if [ -n "$gui" ]; then | |
cmd="rofi -dmenu" | |
else | |
cmd="fzf" | |
fi | |
pacmd list-sinks | | |
awk "$awk_program" | | |
$cmd | | |
awk '{ print $1 }' | | |
xargs -I {} pacmd set-default-sink {} | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment