4

I like to keep my headphones plugged in, then depending on the situation just switch the audio output as needed. I'm easily able to do this in Windows - my headphones and speakers show up as different devices, and I'm able to switch.

In Ubuntu (Kubuntu 18.04) I can't seem to get this to work. After some fiddling, I found that I can disable Automute in alsamixer, and that way I can have sound coming from both speakers and headphones, but I still can't find a way to choose between them. Pulse audio and the kde settings only show one device (Built-in Audio Analog Stereo).

Edit: I was thinking I could probably keep the headphones plugged in, and use a script to enable/disable automute depending on whether I want to listen to headphones/speakers. But this doesn't work because with automute disabled the speaker volume is way lower.

Edit: output of aplay -l as requested:

$ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: PCH [HDA Intel PCH], device 0: ALC1220 Analog [ALC1220 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 0: PCH [HDA Intel PCH], device 1: ALC1220 Digital [ALC1220 Digital]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: GoMic [Samson GoMic], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 7: HDMI 1 [HDMI 1]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 8: HDMI 2 [HDMI 2]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 2: NVidia [HDA NVidia], device 9: HDMI 3 [HDMI 3]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
hoodakaushal
  • 493
  • 1
  • 8
  • 24
  • apt-get install pavucontrol – cmak.fr May 25 '18 at 08:30
  • This doesn't help. The UI it shows is the same as pulse audio volume control. – hoodakaushal May 25 '18 at 17:25
  • not the same. with pavucontrol you can switch from an output to another – cmak.fr May 26 '18 at 08:31
  • Yes, it is the same. Both have an option to switch (they show the option of a port, which has headphones and line out as options), but whenever headphones are plugged in they show line out as plugged out. I tried setting the port as line out anyway, and the result was there was no sound from speakers or headphones. – hoodakaushal May 26 '18 at 16:10
  • @hoodakaushal you are correct - Pulseaudio Volume Control in main menu is same package as using 'pavucontrol' command in terminal – nik gnomic May 29 '18 at 17:03
  • run command 'aplay-l' to get information on audio device and add response to your OP. if there is only one sub-device shown for Built-in Audio Analog Stereo playback you won't be able to run speakers and headphones independently. you probably don't need a full script to turn automute on or off, one 'amixer' command would probably do it. once you find the right command that works in terminal can make a desktop/panel/dock button to make it available on desktop – nik gnomic May 29 '18 at 17:07
  • @nikgnomic added aplay output, it looks like the output lists two subdevices (the output is the same whether i have automute on or off in alsamixer) – hoodakaushal May 30 '18 at 17:55

2 Answers2

0

To keep headphones plugged in, set auto-mute option in ALSA to off

preferable initial state is to have both speakers and headphones playing audio

Get exact names of ALSA control elements (Case sensitive) from alsamixer or use terminal command:

amixer -c 0

Create launcher buttons to toggle mute on or off on desktop,panel,dock etc

launcher command is

amixer -c 0 [name] toggle

replace [name] with correct name of ALSA element to mute/unmute

  • I've already mentioned why I don't want to do this - if I disable automute, speaker volume is way lower when headphones are connected. – hoodakaushal Jun 01 '18 at 14:08
  • before you mentioned "with automute the speaker volume is way lower" With automute enabled + jack always plugged in, speakers would always be muted. with those conditions, answer to main question is no, unless you use GoMic output as independent headphone channel – nik gnomic Jun 02 '18 at 02:52
  • Sorry, I meant with automute disabled. – hoodakaushal Jun 03 '18 at 08:14
0

See my answer for 18.04 - it also works for 16.04.

Once I followed these instructions, my Line Out and Headphones (mine is actually a headset with mic) started appearing separately in the Ubuntu 16.04 'Sound' app whereas before there was only one or the other displayed. I can swap the output device using by clicking on it in the Sound app.

Ubuntu 16.04 'Sound' app

In brief, you need to edit Pulseaudio mixer's configuration files:

  • /usr/share/pulseaudio/alsa-mixer/paths/analog-output-lineout.conf
  • /usr/share/pulseaudio/alsa-mixer/paths/analog-output-headphones.conf
Jaydin
  • 1,446