dmenu-audio (951B)
1 #!/usr/bin/sh 2 # choose pulseaudio sink via dmenu 3 # changes default sink and moves all streams to that sink 4 5 # get all sink ids and descriptions 6 sources=$(pacmd list-sinks) 7 sinknames=$(echo "$sources" | grep "device.description" | awk -F '"' '{print $2}') 8 sinkids=$(echo "$sources" | grep "name: "| awk '{print substr($2,2,length($2)-2)}') 9 10 # choose one sink by description 11 namechosen=$(echo "$sinknames" | dmenu -l 10 -p "audio:") 12 [[ -z $namechosen ]] && echo "Cancelled." && exit 13 14 # get the corresponding id for the chosen sink 15 numberchosen=$(echo "$sinknames" | awk -v var="$namechosen" '{if ($0 == var) {print FNR}}') 16 idchosen=$(echo "$sinkids" | awk -v var="$numberchosen" '{if (FNR == var) {print $0}}') 17 18 # set as default 19 pactl set-default-sink "$idchosen" 20 21 # move all streams to the new sink 22 for input in $(pactl list short sink-inputs | awk '{print $1}');do 23 pactl move-sink-input "$input" "$idchosen" 24 done 25 26 # update statusbar 27 sigdwmblocks 5