Skip to content

Instantly share code, notes, and snippets.

@kafene
Created May 18, 2017 08:00
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kafene/32a07cac0373409e31f5bfe981eefb19 to your computer and use it in GitHub Desktop.
Save kafene/32a07cac0373409e31f5bfe981eefb19 to your computer and use it in GitHub Desktop.
Pulseaudio via systemd --user

~/.config/systemd/user/pulseaudio.service:

[Unit]
Description=Pulseaudio Sound Service
Requires=pulseaudio.socket

[Service]
Type=notify
ExecStart=/usr/bin/pulseaudio --verbose --daemonize=no
ExecStartPost=/usr/bin/pactl load-module module-alsa-sink
Restart=on-failure

[Install]
Also=pulseaudio.socket
WantedBy=default.target

~/.config/systemd/user/pulseaudio.socket:

[Unit]
Description=Pulseaudio Sound System

[Socket]
Priority=6
Backlog=5
ListenStream=%t/pulse/native

[Install]
WantedBy=sockets.target

To start:

pulseaudio --kill
systemctl --user daemon-reload
systemctl --user enable pulseaudio.service
systemctl --user enable pulseaudio.socket
systemctl --user start pulseaudio.service
systemctl --user status pulseaudio.{service,socket}
@anantha-vidhya
Copy link

The above commands are not working in embedded linux with tisdk 05-03 on am5728 board.
They showing as below.
root@am57xx-evm:/usr/lib/systemd/user# pulseaudio --kill
E: [pulseaudio] main.c: Failed to kill daemon: No such process
root@am57xx-evm:/usr/lib/systemd/user# systemctl --user daemon-reload
Failed to connect to bus: No such file or directory
root@am57xx-evm:/usr/lib/systemd/user# systemctl --user enable pulseaudio.service
Failed to connect to bus: No such file or directory

Please if you have any idea on this help me in this regard.

Thanks & Regards
A.N.V.Lavanya

@kafene
Copy link
Author

kafene commented Oct 18, 2021

Sorry no idea, this is 5 years old it probably worked back then but the software has changed.

@imbezol
Copy link

imbezol commented Jan 26, 2022

I believe you need to run the commands as the user for which you are trying to disable the service; don't do it as root.

@kosciuk
Copy link

kosciuk commented Jul 8, 2022

I paste only the commands and works on Ubuntu 22.10 (dev)

@rwjack
Copy link

rwjack commented Oct 6, 2022

worked like a charm in late 2022. thx

This oneliner also works:
systemctl --user --now enable pulseaudio.service pulseaudio.socket

@Kornelius777
Copy link

Works like a charm!
Thank you very much for publishing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment