How to: Tips and Tricks

Ubuntu: Make ALSA default instead of PulseAudio

PulseAudio has still problems with some applications and it always adds a little latency and that's the reason, why so many people still prefer ALSA. This howto shows you, how to remove PulseAudio, add alsa-mixer applet to the panel and associate hotkeys for volume change.

1. Remove PulseAudio

This will uninstall PulseAudio, delete the configuration files and uninstall it's dependencies; gstreamer-10-pulseaudio, libpulse-browse0, libpeexdsp1, pulseaudio-esound-compat, pulseaudio-module-udev, pulseaudio-module-x11, pulseaudio-utils, rtkit and gnome-desktop (don't worry, it is dummy package):

sudo apt-get purge pulseaudio

2. Install alsa-mixer (volume) applet

PulseAudio removes volume applet, so you need new volume applet. For getting it to work, you need to intall the following packages: python, python-notify, python-gtk2, python-alsaaudio and xfce4-mixer or gnome-alsamixer (i preffer xfce4-mixer).

sudo apt-get install python python-notify python-gtk2 python-alsaaudio python-eggtrayicon xfce4-mixer

Download alsamixer-applet:

wget http://howto.blbosti.com/files/alsa/alsa_mixer_applet_1.1.tar.gz

Extract all files for example into /usr/local/bin direcotry:

sudo tar -C /usr/local/bin/ -xzvf alsa_mixer_applet_1.1.tar.gz

Make all files executable (if they're not):

cd /usr/local/bin
sudo chmod +x alsa*
sudo chmod +x volbar.py

If you want to use your keyboard's volume hotkeys, you have to set them in System > Preferences > Keyboard Shortcuts. Click Add.

Name:      ALSA Volume mute
Command:   /usr/local/bin/alsa_master_mute
Name:      ALSA Volume down
Command:   /usr/local/bin/alsa_master_down
Name:      ALSA Volume up
Command:   /usr/local/bin/alsa_master_up

Then click on Disabled in the second column and map your hotkeys for these actions.

Finally the programs volbar.py and alsavol.py have to be set to start automatically. This can be set under System > Preferences > Startup Applications. Click Add:

Name: volbar
Command: /usr/local/bin/volbar.py

Name: alsavol
Command: /usr/local/bin/alsavol.py

Note: If you have installed gnome-alsamixer instead of xfce4-mixer, you need to edit volbar.py

sudo gedit /usr/local/bin/volbar.py

Find the line 97 and replace xfce4-mixer to gnome-alsamixer:

subprocess.Popen("gnome-alsamixer")

Now restart your computer and test, if everything is working.

A click on the tray icon opens the slider.

volume slider

Double-clicking opens the mixer.

xfce4-mixer

Use hotkeys to change volume – these changes will be shown via libnotify.

volume libnotify

Note: Unfortunately, this solution is not perfect, because Totem does not play audio and in Nautilus does not work audio preview on mouse over. If you have any other solution, please, let me know.

UPDATE

ThomasEgi wrote another solution:

Instead of removing pulseaudio you can also stop if from auto-restarting and simply killing it of with an auto-starter each time you login.

echo autospawn = no|tee -a ~/.pulse/client.conf && killall pulseaudio

After that, simply put killall plulseaudio into your autostart. You still need the alsa-mixer stuff and totem/audio-preview are also broken. but it’s quite useful for when you want to temporarily switch to alsa or any other sound system.

Files to download:

Edit: I found another way at webupd8.org.

Credit goes here and here.

  • Luckily there is still XFCE4 and Xubuntu to get it out of the box.
    Uninstalling pulseaudio, so far, has been a matter of a single uninstall command line command.
    Ubuntu itself has been going downhill in a hurry.
    If Xubuntu loses its value (it has not so far), or if the fanatic pulseaudio zealots figure out a way how to force it onto people by making it not possible to uninstall, then we’ll have to look for another distribution. Perhaps back to Fedora, or SUSE, or try out the Gentoo thing.

  • Amen,Mike and others. At 79, I just don’t have enough time left to screw around trying to solve these problems that seem to me should have been solved before the newest version appears. I’m losing hours over getting K3B to function properly too. I wonder how many I have left.

  • Enjoy, Thank you for this simple, straight forward walkthrough. I’m extremely new to linux and terminal commands and your steps helped me out a lot. I had already purged pulseaudio when I stumbled upon this page, looking for a way to get my keyboard sound controls working again and an applet. After following your steps I have audio controls back without having to keep an alsamixer window locked to my unity bar. However, the alsa volume applet isn’t working/isn’t there in the tray at all. Its not a big deal to me because I have my keyboard shortcuts, but I’m interested Why nobody else has reported this problem. Possibly because I’m running 12.04??

  • Hi Bryce, I suppose it’s because you’re running 12.04. This tutorial was for 9.10 & 10.04. I haven’t tried it in newer versions because since 10.10 I’m an Arch user. Sorry…

  • Ya that makes sense, well you can’t expect everything to be perfect :) Thanks for what help it was.

  • Bryce, in 12.04, if you changed it to the ‘gnome-classic’, the hotkey to get into the top panel is ++right mouse click. The Unity desktop is pretty, but not for me.

  • That would be Suoper-key+Alt-key+right mouse click. Guess left and right carrot characters got interpreted as html. Sorry.

  • Yeah I have 12.04 and this did not work. I have NO sound at all now.

  • NOT worked for me in 10.04.4 after removing pulseaudio and played with that commands. But thanks for sharing and help people.

    Cheers

  • With luck, this will work in Debian-based systems as well. I’ll try it later.

  • Thank you so much! I couldn’t for the life of me figure out why my system froze trying to play sound, but I followed your steps here and it worked! The problem must be with Pulseaudio then.

  • Also, I’m running Xubuntu 12.04.

  • note that when adding keyboard shortcuts I needed to add file extension .py to these files via sudo gedit then save as function :

    /usr/local/bin/alsa_master_mute
    /usr/local/bin/alsa_master_down
    /usr/local/bin/alsa_master_up

    Thanks sound is working now.

  • Ubuntu 12.04
    /usr/local/bin/volbar.py:202: GtkWarning: Invalid icon size 0

  • thanks, for your info, I uninstalled VLC and the problems of no audio in ubuntu 15.04 got resolved. Weird that a bug cannot get fixed by realtek, VLC and Ubuntu in 4 years.

  • I fix the problem of No sound, by uninstalling VLC. Ubuntu 15.04 with Linux 4.1.0-040100rc6-generic #201506010235. MSI laptop Mega Book VR600….I know my hardware is old 2007. But 4 years later and the same bug from Realtek, VLC and Ubuntu cannot be fixed, yeah next year will be the year of linux and ubuntu,,,whatever

  • I dig you and feel you, here I am in 2015 with the same problem of no sound each time you update ubuntu or linux kernel …. I fix the problem of No sound, by uninstalling VLC. …….. Ubuntu 15.04 with
    Linux 4.1.0-040100rc6-generic #201506010235. MSI laptop Mega Book
    VR600….I know my hardware is old 2007.

  • All good, but firefox cannot play any sound…