daemon: Rely on systemd unit file for X11 plugin initialization

For GNOME X11 sessions, avoid relying on xdg autostart desktop files
to initialize the X11 plugins. This is now handled via a systemd unit
file.

The xdg autostart is still installed, but has been made to instruct
GNOME to skip it with X-GNOME-HiddenUnderSystemd. This is still the
primary way to initialize X11 plugins for other DEs.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/467>
This commit is contained in:
Carlos Garnacho 2020-11-04 11:16:27 +01:00 committed by PulseAudio Marge Bot
parent a155cf8ca5
commit 4868fcf5f3
3 changed files with 29 additions and 0 deletions

View file

@ -152,6 +152,8 @@ endif
if systemd_dep.found()
sd_user_service_conf = configuration_data()
sd_user_service_conf.set('PA_BINARY', cdata.get_unquoted('PA_BINARY'))
sd_user_service_conf.set('PACTL_BINARY', join_paths(bindir, 'pactl'))
sd_user_service_conf.set('PA_X11_BINARY', join_paths(bindir, 'start-pulseaudio-x11'))
sd_user_service_file = configure_file(
input : 'systemd/user/pulseaudio.service.in',
@ -161,6 +163,14 @@ if systemd_dep.found()
install_dir : systemduserunitdir,
)
sd_user_x11_service_file = configure_file(
input : 'systemd/user/pulseaudio-x11.service.in',
output : 'pulseaudio-x11.service',
configuration : sd_user_service_conf,
install : true,
install_dir : systemduserunitdir,
)
install_data('systemd/user/pulseaudio.socket',
install_dir: systemduserunitdir,
)

View file

@ -6,4 +6,5 @@ Exec=start-pulseaudio-x11
Terminal=false
Type=Application
X-GNOME-Autostart-Phase=Initialization
X-GNOME-HiddenUnderSystemd=true
X-KDE-autostart-phase=1

View file

@ -0,0 +1,18 @@
[Unit]
Description=Sound Service (X11 Plugins)
Requires=pulseaudio.service
After=pulseaudio.service
ConditionUser=!root
PartOf=gnome-session-x11.target
[Service]
ExecStart=@PA_X11_BINARY@
ExecStop=@PA_X11_BINARY@ stop
LockPersonality=yes
MemoryDenyWriteExecute=yes
NoNewPrivileges=yes
RestrictNamespaces=yes
SystemCallArchitectures=native
SystemCallFilter=@system-service
Type=simple
UMask=0077