szclsya / mpdris2-rs

Exposing MPRIS V2.2 D-Bus interface for mpd
GNU General Public License v3.0
31 stars 1 forks source link

playerctl cannot find player when using systemd service #4

Open J4ckTh3R1pper opened 1 year ago

J4ckTh3R1pper commented 1 year ago

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

J4ckTh3R1pper commented 1 year ago

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...

szclsya commented 1 year ago

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

J4ckTh3R1pper commented 1 year ago

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

Hyprland WM, running as user service

szclsya commented 1 year ago

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