You are not logged in.

#1 2020-05-31 12:43:59

notmilad
Member
Registered: 2020-05-31
Posts: 9

systemd service to call pasuspender after wake up fails

I have problems with `pulseaudio` when resuming from suspend and the official arch wiki suggests doing:

`$ /usr/bin/pasuspender /bin/true`

This does in fact solves my issue but [their suggestion for turning this into a systemd service](https://wiki.archlinux.org/index.php/Pu … om_suspend) does not work me. This is the content of the service


[Unit]
Description=Fix PulseAudio after resume from suspend
After=suspend.target

[Service]
User=%I
Type=oneshot
Environment="XDG_RUNTIME_DIR=/run/user/%U"
ExecStart=/usr/bin/pasuspender /bin/true

[Install]
WantedBy=suspend.target

and systemd status:

systemctl status resume-fix-pulseaudio@milad.service
● resume-fix-pulseaudio@milad.service - Fix PulseAudio after resume from suspend
     Loaded: loaded (/etc/systemd/system/resume-fix-pulseaudio@.service; enabled; vendor preset: disabled)
     Active: failed (Result: exit-code) since Sun 2020-05-31 13:28:57 BST; 4s ago
    Process: 150033 ExecStart=/usr/bin/pasuspender /bin/true (code=exited, status=1/FAILURE)
   Main PID: 150033 (code=exited, status=1/FAILURE)

May 31 13:28:57 milad-pc systemd[1]: Starting Fix PulseAudio after resume from suspend...
May 31 13:28:57 milad-pc pasuspender[150033]: XDG_RUNTIME_DIR (/run/user/0) is not owned by us (uid 1000), but by uid 0! (This could e.g. h>
May 31 13:28:57 milad-pc pasuspender[150033]: Connection failure: Connection refused
May 31 13:28:57 milad-pc pasuspender[150033]: pa_context_connect() failed: Invalid argument
May 31 13:28:57 milad-pc systemd[1]: resume-fix-pulseaudio@milad.service: Main process exited, code=exited, status=1/FAILURE
May 31 13:28:57 milad-pc systemd[1]: resume-fix-pulseaudio@milad.service: Failed with result 'exit-code'.
May 31 13:28:57 milad-pc systemd[1]: Failed to start Fix PulseAudio after resume from suspend.

Any ideas what's going wrong?

Last edited by notmilad (2020-05-31 12:44:57)

Offline

#2 2020-05-31 14:33:35

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 25,064

Re: systemd service to call pasuspender after wake up fails

The wiki's wrong, see man systemd.unit

       │"%U"      │ User UID                      │ This is the numeric UID of    │
       │          │                               │ the user running the service  │
       │          │                               │ manager instance. In case of  │
       │          │                               │ the system manager this       │
       │          │                               │ resolves to "0".              │
       │          │                               │                               │
       │          │                               │ Note that this setting is not │
       │          │                               │ influenced by the User=       │
       │          │                               │ setting configurable in the   │
       │          │                               │ [Service] section of the      │
       │          │                               │ service unit.

After some general manual scourging you probably rather want something like

[Unit]
Description=Fix PulseAudio after resume from suspend
After=suspend.target

[Service]
User=%I
Type=oneshot
PAMname=systemd-user
ExecStart=/usr/bin/pasuspender /bin/true

[Install]
WantedBy=suspend.target

or just do it simpler, use the UID as the instance identifier (i.e. 1000) and use %i instead of %u on the environment line.

Offline

#3 2020-05-31 16:06:49

notmilad
Member
Registered: 2020-05-31
Posts: 9

Re: systemd service to call pasuspender after wake up fails

Interesting! That does get rid of the permission error but the `Connection failure: Connection refused` and `pa_context_connect() failed: Invalid argument` errors remain.

Offline

Board footer

Powered by FluxBB