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.