4

At work I use to use an USB headset which gets detected as separate audio output and input (for the mic) devices. At home I use conventional analogue headset which is plugged into my laptop built-in sound system with headphone/mic jacks.

Every time I want to switch between the USB headset and my laptop built-in sound system I have to open PulseAudio control panel and select the device.

Can't I just make a couple of command line shortcuts to do the switch?

UPDATE: I've just came to even more interesting idea than using CLI-based shortcuts manually - I think It is possible to trigger their launching on the USB headset attachment/detachment detection.

2 Answers 2

1

PulseAudio has got a command line interface. You can read about it on the official wiki.

You didn't mention witch distro You use, but with the default package manager it should be easy to search after the PulseAudio CLI package.

Basically you search the command which does the job for You, then You can create an alias command in Your ~/.bash_profile or ~/.bashrc with:

# cs like change source
alias cs='<command>'
1

To connect a Bluetooth device and set it as the default PulseAudio output ("sink") from the command line:

# List paired devices
$ echo "list devices" | bluetoothctl
...
[NEW] Device 01:23:45:67:89:AB MyDevice
...

# Connect
echo "connect 01:23:45:67:89:AB" | bluetoothctl

# List PulseAudio sinks:
$ pactl list sinks | grep 'Name: '
....
Name: bluez_sink.01_23_45_67_89_AB.a2dp_sink

# Set default to Bluetooth device
pactl set-default-sink bluez_sink.01_23_45_67_89_AB.a2dp_sink

Be aware that this may not switch the audio output of programs that are already running.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .