I have two audio outputs: one is a wireless headset, the other is my laptop's built-in 3.5mm jack. How do I switch between them via the terminal? Ultimately, I want to assign a keyboard shortcut to do the switch.
Asked
Active
Viewed 365 times
1 Answers
0
I built a script which does the switching. I call it using xbindkeys. I'm sure it could be improved, because I'm not very good with grep, and it's not ideal that the script works on the basis of numbers instead of names. The script is big because it takes a lot of effort to automate the process, but here are the essential parts:
# Identify any active sink inputs (audio streams - identified by number).
pacmd list-sink-inputs
# Identify the next sink (output - identified by number or by name).
pacmd list-sinks
# Switch the sink input to the next sink.
pactl move-sink-input "$sink_input" "$next_sink"
# Change the default sink to the next one.
pactl set-default-sink "$next_sink"
wjandrea
- 14,504