From 4868fcf5f344af613172f61d9105c02f3f07e1ab Mon Sep 17 00:00:00 2001 From: Carlos Garnacho Date: Wed, 4 Nov 2020 11:16:27 +0100 Subject: [PATCH] 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: --- src/daemon/meson.build | 10 ++++++++++ src/daemon/pulseaudio.desktop.in | 1 + .../systemd/user/pulseaudio-x11.service.in | 18 ++++++++++++++++++ 3 files changed, 29 insertions(+) create mode 100644 src/daemon/systemd/user/pulseaudio-x11.service.in diff --git a/src/daemon/meson.build b/src/daemon/meson.build index 2d0154fff..c33e148b5 100644 --- a/src/daemon/meson.build +++ b/src/daemon/meson.build @@ -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, ) diff --git a/src/daemon/pulseaudio.desktop.in b/src/daemon/pulseaudio.desktop.in index 2e85202f7..9af72fe71 100644 --- a/src/daemon/pulseaudio.desktop.in +++ b/src/daemon/pulseaudio.desktop.in @@ -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 diff --git a/src/daemon/systemd/user/pulseaudio-x11.service.in b/src/daemon/systemd/user/pulseaudio-x11.service.in new file mode 100644 index 000000000..d6f3bd426 --- /dev/null +++ b/src/daemon/systemd/user/pulseaudio-x11.service.in @@ -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