Sample Header Ad - 728x90

Use dbus to get name of mediaplayer currently playing

4 votes
2 answers
5015 views
**EDIT: I removed and rewrote most of the post to make the question more direct and to make the post a lot shorter. You can of course view the edit history to get the previous version.** Using bspwm on Arch Linux. playerctl to control media, sxhkd to bind media keys to playerctl commands. I'm trying to find a way to get the latest active media player so when I use the media keys to play/pause a song/movie/.. , my pc automatically controls the latest active mediaplayer. For instance, when Spotify happens to be open in the background and I'm watching something on VLC, it knows to control VLC and not Spotify when I press media keys. Right now, if both are open, VLC always gets priority from playerctl. What I need is a way to ask dbus which mediaplayer is currently playing a song, so I can keep it in a file. --- EDIT: I found a way to ask each spotify and vlc using: qdbus org.mpris.MediaPlayer2.vlc /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlaybackStatus and qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlaybackStatus but I'd like to automatically ask **all** mediaplayers, not each one by name. I tried to do it with org.mpris.MediaPlayer2.* but that doesn't work. Any ideas?
Asked by zjeffer (495 rep)
Oct 25, 2018, 07:33 PM
Last activity: Feb 2, 2020, 02:22 PM