When I press the mute key on my keyboard, both the Alsa master channel and the PulseAudio master channel get muted, pressing it again only unmutes the alsa master channel, the pulseaudio master channel keeps muted. Result: no sound. How do I fix that?
10 Answers
it is much simplier though.
amixer -D pulse set Master Playback Switch toggle
set this as a hotkey to "Mute\Unmute". volume controls can be left as they are.
Mint 15 Mate - figured it out by myself, works fine for me.
-
Whatever it is - worked well on arch linux. Muted and unmuted sound successfully. Now I binded this command on mute command on my laptop, because a default one doesnt unmute all channels. THANKS– ErikasOct 6, 2014 at 6:05
-
This worked for me with Ubuntu 14.04 + i3, the accepted answer didn't work. Nov 22, 2014 at 20:02
-
1
amixer -D pulse set Master toggle
will do. Amixer expects a simple mixer control name for set or sset command, and even if it accepted a complete mixer control name, you would have to quote such a multi-word name. You may use the optional modifierplayback
in the command like this:amixer -D pulse set Master playback toggle
, but it is unnecessary, ifMaster
does not have capture capabilities as well. By using optional modifiers you may also control to which channels the command applies, if your system is surround sound capable.– jarnoApr 15, 2015 at 6:58 -
2020, but in case anyone else needs this:
amixer -c <card-number>
will list all the controls the card has. in my case, instead ofMaster
I usedPCM
. Oct 18, 2020 at 19:24
Run this command:
amixer -D pulse set Master 1+ unmute
-
12
-
1What is that 1+ for? I could not find an explanation in the man page of amixer.– jarnoApr 15, 2015 at 6:24
-
using toggle instead of unmute is useful if you are binding the command to a hardware key
amixer -D pulse set Master 1+ toggle
Nov 29, 2017 at 15:05 -
I was about to ask the same question. But a search dropped me here so I just want to say this is working pretty fine for a hardware based solution on Ubuntu 20.04 and i3WM Nov 19, 2020 at 1:49
I had the same problem running MATE desktop on a Linux Mint Debian Edition (201204).
"Volume up" action was not able to unmute the volume. I realised that the problem was with Pulseaudio, but the package mate-media-gstreamer
and mate-settings-daemon-gstreamer
where installed by default. By installing mate-media-pulse
and mate-settings-daemon-pulse
(that uninstalled mate-media-gstreamer
and mate-settings-daemon-gstreamer
) and tadam... "Volume up" action was able to unmute the volume again !
I hope this will also work for you!
-
Worked for me (on Debian Jessie) and this solution is permanent, whereas AFAIU solutions involving
amixer -D pulse set Master xxx
are one shot, or need to be mapped manually to a shortcut. Solution proposed here looks like the way it is meant to be.– JérômeJun 12, 2015 at 17:53
It is a problem with pulseaudio,the commands for alsa or amixer will not properly send unmute to pulse. When alsa commands send a mute signal it is a toggle command(send the same command to mute/unmute).
Now in pulseaudio they have separate mute and unmute code! Many report that un-installing pulseaudio will solve the problem, but for some that is not really an acceptable answer (like me, because pulse is useful for many apps).
So to solve this we need to make a script,
1- Make a new empty doccument in a text editor like gedit or mousepad,
2- Paste this code in the doccument, Soruce of code:2
#!/bin/bash
#### Create ~/.pulse/mute if not exists
ls ~/.pulse/mute &> /dev/null
if [[ $? != 0 ]]
then
echo "false" > ~/.pulse/mute
fi
####Create ~/.pulse/volume if not exists
ls ~/.pulse/volume &> /dev/null
if [[ $? != 0 ]]
then
echo "65536" > ~/.pulse/volume
fi
CURVOL=`cat ~/.pulse/volume` #Reads in the current volume
MUTE=`cat ~/.pulse/mute` #Reads mute state
if [[ $1 == "increase" ]]
then
CURVOL=$(($CURVOL + 3277)) #3277 is 5% of the total volume, you can change this to suit your needs.
if [[ $CURVOL -ge 65536 ]]
then
CURVOL=65536
fi
elif [[ $1 == "decrease" ]]
then
CURVOL=$(($CURVOL - 3277))
if [[ $CURVOL -le 0 ]]
then
CURVOL=0
fi
elif [[ $1 == "mute" ]]
then
if [[ $MUTE == "false" ]]
then
pactl set-sink-mute 0 1
echo "true" > ~/.pulse/mute
exit
else
pactl set-sink-mute 0 0
echo "false" > ~/.pulse/mute
exit
fi
fi
pactl set-sink-volume 0 $CURVOL
echo $CURVOL > ~/.pulse/volume # Write the new volume to disk to be read the next time the script is run.
3- Name the file "volume" (no extension needed) put it somewhere you can find and won't delete it like your home folder
4- Make the file executable by Right-clicking on the file, go to Properties, then the Permissions tab, and use the check box to mark it executable, this will allow the script to be run. mark-file-as-executible-gui
5- Next we need to link the commands to the keyboard, the commands for the code are increase, decrease, and mute.
So go to the keyboard settings - how-do-i-change-my-keyboard-shortcuts-in-xubuntu, In the keyboard shortcuts area, click add, then open, Open the "volume" file we created, then add the command for the code after volume, reading volume increase, or volume mute ect. but with the location of where the code file is before it like "/home/username/volume mute"
Then assign it to the keyboard by pressing the key it, or if the key is already used,
~ Most likely the case ~ find them and replace the command.
The key shortcuts are likely called XF86AudioRaiseVolume, XF86AudioLowerVolume, XF86AudioMute. Since only the mute is broken concentrate your efforts on changing that out first.
Bug: 1
-
I just have
XF86AudioMute
mapped to the commandamixer set Master toggle
. The raise and lower vol keys get mapped similarly toamixer
commands. May 1, 2012 at 5:00 -
@Chan-HoSuh are you having the same problem? you can just call on the mute command of this script if you want, for some reason pulse was intercepting the mute on my machine, the amixer sends a toggle, which is interpreted as just mute by pulse, or just intercepting the key press? I was using a similar script that showed a volume bar before :( , but this mutes and unmutes, and they now have the notifications, so it's all good, the toggle is how it was set up before.– MateoMay 1, 2012 at 5:25
-
One small improvement to the script is to also force unmute on volume increase/decrease. I also added 'paplay /usr/share/sounds/ubuntu/stereo/message.ogg' to get feedback on the volume.– dmaJan 28, 2014 at 0:18
-
Maybe it was different before, but with pulseaudio 4.0 you can use commands like
pactl set-sink-volume 0 +5%
,pactl set-sink-volume 0 -5%
andpactl set-sink-mute 0 toggle
to increase volume, decrease volume and toggle volume, respectively.– jarnoApr 15, 2015 at 7:22 -
@jarno yeah, this was to solve a specific problem (bug) so it is likely fixed/not as relevant, but it remains a nice little hack if nothing else works– MateoApr 15, 2015 at 9:33
See:
https://bugs.launchpad.net/xfce4-volumed/+bug/883485/comments/3
xfce4-mixer has a setting for active-card
, that must be set to Pulseaudio, otherwise it will be using Alsa.
Worked for me on 12.10:
#!/bin/sh
amixer -c 0 sset Master,0 mute
sleep 5
amixer -D pulse set Master 1+ unmute
For KDE and kmix users, if you use this script you will still have the visual feedback working:
#! /bin/bash
DBUS=qdbus 2> /dev/null
case "$1" in
volup)
pactl set-sink-mute alsa_output.pci-0000_00_1b.0.analog-stereo 0
${DBUS} org.kde.kmix /kmix/KMixWindow/actions/increase_volume com.trolltech.Qt.QAction.trigger
;;
voldn)
pactl set-sink-mute alsa_output.pci-0000_00_1b.0.analog-stereo 0
${DBUS} org.kde.kmix /kmix/KMixWindow/actions/decrease_volume com.trolltech.Qt.QAction.trigger
;;
mute)
${DBUS} org.kde.kmix /kmix/KMixWindow/actions/mute com.trolltech.Qt.QAction.trigger
pactl set-sink-mute alsa_output.pci-0000_00_1b.0.analog-stereo $(${DBUS} org.kde.kmix /Mixers/0/Master_0 org.kde.KMix.Control.mute | sed 's/false/0/g;s/true/1/g')
;;
*)
echo "Usage: mixctl <volup|voldn|mute>" >&2
exit 1
;;
esac
exit 0
Usage:
1) Save it as ~/bin/mixctl
2) Unmap the default kmix keyboard shortcuts for Volume Up/Volume Down and Mute
3) Create three new custom keyboard shortcuts named 'Volume Up', 'Volume Down' and 'Mute'
--> shortcut type: command
--> as the commands use ~/bin/mixctl volup, ~/bin/mixctl voldn and ~/bin/mixctl mute respectively
I had the same problem on multiple Xubuntu 12.04 machines which were upgraded to XFCE 4.10.
Here is a very quick way solve this problem from the command line (or with a bash
script).
Unlike previous solutions which offer stop-gap scripts, this solution fully restores the function of the mute/unmute button.
Simply issue the following two commands once, to resolve the problem once and for all:
$ xfconf-query --channel xfce4-mixer --property /active-card --set PlaybackInternalAudioAnalogStereoPulseAudioMixer --reset
$ xfconf-query --create --channel xfce4-keyboard-shortcuts --property /commands/custom/XF86AudioMute --type string --set 'amixer -D pulse set Master 1+ toggle'
I found a simple solution that works well for me in this forum. In detail, you need to add this to /etc/asound.conf
:
pcm.pulse {
type pulse
}
ctl.pulse {
type pulse
}
pcm.!default {
type pulse
}
ctl.!default {
type pulse
}
And then set a keyboard shortcut for the mute key with the command being:
amixer set Master toggle
You can use the keyboard settings to set the mute button to execute the command found HERE. Although the first method listed on this link was useless for me, the second one works great for XFCE4: $ pactl set-sink-mute 0 toggle
. You can also create a script or launcher to execute the command on mouse click.
FYI, if you're using something like Cinnamon (and probably other gnome-based desktops)
user197761's above suggestion seems better, as cinnamon's sound applet recognizes the volume is muted: amixer -D pulse set Master Playback Switch toggle
(if you like this latter command, please upvote his/her answer, not mine.)