2

I have been looking for an answer for this and couldn't find one. I am trying to mute/un-mute the built-in speakers of my computer from the command line without affecting the external speakers connected to the output jack of the sound card.

So far I found these commands to mute/un-mute from the command line, but both commands also mute/un-mute the external speakers:

pactl set-sink-mute 1 0

amixer sset Speaker mute

I am running Ubuntu 13.10 on a dell optiplex 760 Pentium 4

The sink 0 device is the HDMI audio output of the nVidia video card, but I'm not interested in that one for this script.

It seems the sink 1 device controls both the builtin speakers and the external output speakers. I can´t find a way to distinguish between both. Any ideas?

If you need more information that can point me to a solution please let me know.

  • Can external and internal speakers be on at the same time? – Volker Siegel Jul 29 '14 at 17:19
  • @Volker No. You have to chose which output to use: i.stack.imgur.com/kIk6m.png – Tim Jul 29 '14 at 17:41
  • Can you open pavucontrol? Maybe you need to install it. – Volker Siegel Jul 29 '14 at 17:48
  • On the output tab, I have separate controls for two devices, inclusive mute. – Volker Siegel Jul 29 '14 at 17:50
  • hi, thanks for the input. I found the solution to my problem but can´t post it until a couple of hours because of my newbie reputation. i have to wait a couple more hours to be able to post it – nanjiro Jul 29 '14 at 21:04
2

From the command line interface of pulseaudio, you can list all sinks (as in "places where sound stream goes away") like this:

pactl list short sinks

0 alsa_output.pci-0000_02_00.1.hdmi-stereo   module-alsa-card.c s16le 2ch 44100Hz SUSPENDED
1 alsa_output.pci-0000_00_1b.0.iec958-stereo module-alsa-card.c s16le 2ch 44100Hz RUNNING

Now, you can work with the separate sinks, and have all the details.

You can use the full name of the sink as arument:

`pactl set-sink-mute alsa_output.pci-0000_00_1b.0.iec958-stereo toggle`


You can instead of the long name, use the index number listed in front of the name (1):

Toggle mute, that is switch between sound on and off:
pactl set-sink-mute 1 toggle

Switch mute on, that is sound off:
pactl set-sink-mute 1 1

Switch mute off, that is sound on:
pactl set-sink-mute 1 0


See pactl help or man pactl for more options.

  • 1
    Thanks for the answer! This works perfectly when the output devices are in different sinks. The problem I had is that the outputs I want to toggle are 2 different ports of the same sink. To differentiate them I used the command "pacmd list-cards". At the bottom it lists the different ports for the sink. Then I activate the one that I want with "pacmd set-sink-port SINK PORT_NAME". In my case I had ports named: analog-output-speaker and analog-output-headphones for the same sink. By activating analog-output-headphones, it disables the builtin audio, which is what I needed – nanjiro Jul 29 '14 at 22:23
  • 1
    Looking at the output of pacmd list-cards - interesting, I see various ports too... You could make a self-answer from this, if it may be helpful for others? I think it is! Should I integrate it into the end of my answer? Seems useful, I think. I learned already from it. – Volker Siegel Jul 29 '14 at 23:03
  • Yeah, definitely. If you want you can add it to your answer. It could probably help others as well. I still can´t post an answer to the question so if you could add it to your answer it would be great. Thanks! – nanjiro Jul 29 '14 at 23:11
  • Oh, we can just wait, and then you make it a full answer. (Now I remember, there is some self-answer wait period - that does not depend on reputation points). But if you edit your own question - that should work allways, I think - and add a section at the bottom, marked with "draft answer - will be added to answer below", I will move it over and integrate it. – Volker Siegel Jul 29 '14 at 23:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.