szclsya/mpdris2-rs

playerctl cannot find player when using systemd service

Opened this issue · 4 comments

This program performed flawlessly inside a terminal , however when using systemd service to run the program, playerctl can't find the mpd player, executing playerctl status only returns "No players found". I think it might be related to user bus, but I don't know how to solve it.
System is Arch Linux, 6.1.8-arch1-1

The systemctl --status output seemed normal, except playerctl can't get any info about MPD

Service started.
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...
:mpd::client] Issuing command to MPD: playlistinfo
:mpd::client] Command playlistinfo returned
:plugins::mpris2::notifier] Waiting for MPD state change from org.mpris2.MediaPlayer2...

Which DE/WM are you using? Also, are you running mpdris2-rs as root or as user service?

Which DE/WM are you using? Also, are you running mpdris2-rs as root or as user service?

Hyprland WM, running as user service

Then you might need to import some environment variables into systemd to make it work. On my sway setup I do this:

systemctl --user import-environment DISPLAY WAYLAND_DISPLAY SWAYSOCK XDG_CURRENT_DESKTOP
dbus-update-activation-environment --systemd WAYLAND_DISPLAY XDG_CURRENT_DESKTOP=sway