I use Pulseaudio to share audio between a desktop and a Raspberry Pi.

However, Pulseaudio needs dbus, and dbus needs an X session. Without graphical session, Pulseaudio is only able to run in system mode, which is officially not recommanded.

Besides on a Raspberry Pi, the cost of an X session is dramatically high, so I would like to get rid of it in the most efficient (less costly) way.

How can I start the smallest X session for Pulseaudio to kick in ?

  • Udev most definitely doesn't need X. I don't know about Pulseaudio: what fails in the absence of X? Is this related to D-Bus? Dec 20, 2013 at 0:13
  • Well I've read that but it might be only Pulseaudio. In the absence of X Pulseaudio is launched in system wide mode, which means no per-user session, which is bad as the official website says : freedesktop.org/wiki/Software/PulseAudio/Documentation/User/…
    – kursus
    Dec 20, 2013 at 0:23
  • Sorry I mixed udev and dbus, edited.
    – kursus
    Dec 20, 2013 at 0:29

2 Answers 2


You can use Xvfb, which is X server with a virtual framebuffer, i.e. an X server that displays only in memory and doesn't connect to any hardware. You don't need to run any client you don't want on that server, and in particular no desktop environment or window manager.

Xvfb :1 -screen 0 1x1x8 &

After this:

DISPLAY=:1 dbus-launch
DISPLAY=:1 pulseaudio --start

You need to wait a little after starting Xvfb for the display to be available. You can use xinit to start an X server and then start clients when it's ready. Put the commands you want to run in a script (note that when the script exits, the X server exits):

pulseaudio --start
sleep 99999999

Start the virtual X server with

xinit /path/to/client.script -- /usr/bin/Xvfb :1 -screen 0 1x1x8

If you want to run it at boot time, you can start it from cron. Run crontab -e (as your user, not as root) and add the line

@reboot xinit /path/to/client.script -- Xvfb :1 -screen 0 1x1x8

If you want to kill this session, kill the xinit process.

  • Sorry to bother I struggle to automatically execute the pulseaudio start command (4th line of your example) at boot. I wonder if it is the DISPLAY property. I tried rc.local, /etc/init.d, rcS, but the script never starts pulseaudio. When I run my script via SSH it works perfectly. I would be glad if you could advice.
    – kursus
    Dec 20, 2013 at 6:30
  • Xvfb has to do some setup before it is ready to accept X connections, so if the later commands run too soon, you may find they fail to connect to the X server. You may want to look into using xinit to start Xvfb, and put those commands in the .xinitrc so that xinit starts them only once Xvfb is ready for them.
    – alanc
    Dec 20, 2013 at 6:33
  • I'm sorry I didn't get you well. Do I have to start Xvfb with .xinitrc ? Right now it is started with rc.local. If so where do I put the PA command ? I tried starting PA command in .xinitrc but no luck, I'm missing something.
    – kursus
    Dec 20, 2013 at 6:48
  • @kursus You need to run all these commands as your user. You can do it from a crontab with @reboot. Also alanc is right, there needs to be a delay after starting Xvfb, and xinit solves this issue. See my edit. Dec 20, 2013 at 9:55
  • Thanks for the edit, it's more clear now. However I get a Unrecognized option: Xvfb when launching the xinit command, with or without the script call.
    – kursus
    Dec 20, 2013 at 18:07

I had the same issue yesterday, using Pulse audio for raspberrypi 0 W with DBus in a headless environment create with yocto without x11 and no systemd, you need to run and export dbus before you run pulseaudio.

if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
     echo "Starting dbus" 
     export $(dbus-launch)

In etc/pulse/client.conf, please enable allow-autospawn-for-root = yes

Run pulseaudio -v to check if there's another problem in your config. Don't use --system switch because it won't be correct.

pulseaudio -D --disallow-exit

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .