Linux: Switch sound output source through PulseAudio in command-line
I’m currently running Ubuntu 20.04.1 LTS an when working from home, I found that switching sound output from one device to another is a pain. One moment I listen to music using my headphones, the other I want to push the sound through the external speakers. Even if I plug any sound device in and select it, the source seldom changes and I cannot control the volume either. I was looking for something a bit more comfortable, than navigating to ‘settings’->’sound’ and choosing the right device. But Linux is all about command-line isn’t it? Well, behold PulseAudio CMD! :)
will list all of the output sinks, which we can normally choose through the UI. I mainly use external Jabra headphones and laptop’s internal speakers. Let’s note their names from the output:
Now it’s just a matter of switching them using this command:
Awesome! But I can’t be expected to remember those identifiers, right? Time for some bash aliases.
Let’s give it a try!
Finally, I don’t have to touch the mouse to set the sound output! Time to go back to work! :)