As the title says, I'm trying to stop Clementine playback using DBus before entering suspend mode. Here is my service file right now:
[Unit] Description=Stop Clementine playback before suspend Requires=dbus.service Before=sleep.target Before=dbus.service [Service] User=jo Type=oneshot ExecStart=-/bin/sh -c 'qdbus org.mpris.clementine /Player org.freedesktop.MediaPlayer.Stop' [Install] WantedBy=sleep.target
Now, this works, i.e. playback is stopped. However, systemd then proceeds to take a long time to actually enter suspend mode. Looking at the logs in journalctl, I see:
Jun 05 23:43:53 localhost.localdomain systemd: Starting Suspend... Jun 05 23:44:18 localhost.localdomain systemd-sleep: Error: org.freedesktop.DBus.Error.NoReply Jun 05 23:44:18 localhost.localdomain systemd-sleep: Did not receive a reply. Possible causes include: the remote application did not send a reply, the Jun 05 23:44:18 localhost.localdomain systemd-sleep: Suspending system...
My first thought is that the DBus system, or maybe Clementine itself is suspended before it has time to reply, thus causing a hang. This is why I tried adding a dependency to the dbus service in my service file above. However, that does not do the trick.