Media Keys Don't Work

Reply

Re: Media Keys Don't Work

ArtGravity
Composer

I found that the suggestion to use mpris-control did exactly what I wanted, and this is no longer problematic for me.

Re: Media Keys Don't Work

MadMartian
Music Fan
Media keys stopped working for me after an update and then started working again suddenly. I checked the version and it's 1:1.0.98.78.gb45d2a6b-10. I don't know if the client was upgraded or a dependent package was upgraded.

Re: Media Keys Don't Work

xkg02s-u_shl
Music Fan

EDIT: my bad. reboot fixed it

The latest snap update 1.1.5.153.gf614956d-16 is not with media keys too on Kubuntu 19.04. It worked with the previous versions (but that couldn't play local files due to a bug). Spotify doesn't show up in the media player widget

Re: Media Keys Don't Work

sleigh_boy
Casual Listener

Spotify 1.0.80.480.g51b03ac3 . Running on Gentoo with Plasma desktop. All media players and browsers work flawlessly with media keys, not Spotify. Alternate media shortcuts via D-Bus commands is a nasty hack. Please address this.

Re: Media Keys Don't Work

MadMartian
Music Fan
Not working again for me either.  I notice it works for awhile after a
reboot but then I think plasmashell or pulseaudio crashed and had to be
restarted and then the media keys stopped working again.
Do the devs read these? I wonder if the code is relying on stale
handles.

Re: Media Keys Don't Work

dchristofolli
Casual Listener

tnx so much

Re: Media Keys Don't Work

6etacat
Casual Listener

I'm using Spotify 1.1.10.546.ge08ef575 on Manjaro Linux. The browser and other software work well with media keys, not Spotify. Please fix this issue. 

Re: Media Keys Don't Work

BlackDex
Regular

There are several items which cause the media-keys not to work.

One is that chrome/chromium can also hijack these key's when you use youtube.

The systems then doesn't know which player to select and it can fail.


I have created a small utility which you can download from github:

https://github.com/BlackDex/mpris-control/releases


I created a special shortcut by using the super+media-keys which work only for spotify by using `mpris-control -t Spotify toggle` for example.


If you find any bugs, please report that at the issues section.

 

Re: Media Keys Don't Work

dimovnike
Casual Listener

You are right... killing chrome solves the issue. It seems that chrome does not release the keys when youtube is closed (if there is such a thing). Thanks.

Re: Media Keys Don't Work

SirScrambly
Regular

How is this still an issue? Spotify, you're a down right travesty. UX, who does that?

Re: Media Keys Don't Work

Lemonase
Visitor
Maybe they feel the dbus/mpris workaround is an acceptable fix. Let's be honest, Linux users are always forced to do this kind of stuff. I agree that it is bad UX though. Spootify plz fix.

Re: Media Keys Don't Work

dchristofolli
Casual Listener

Actually the issue isn't attached by the Ubuntu version, but the desktop environment. The media keys does not works in Unity desktop (Ubuntu 16.04 default), but works in others desktops, like Gnome shell(Ubuntu 18.04 default). For example, if you install gnome session in Ubuntu 16.04, the keys will works perfectly

Re: Media Keys Don't Work

rjbruintjes
Regular

EDIT: Never mind, I spoke too soon! Issue persists.

 

ORIGINAL:

It seems the issue is finally fixed! My media keys are suddenly working again. 🙂

Re: Media Keys Don't Work

ArtGravity
Composer

I'm glad to hear that. Now I just have to remember to to deactivate the workaround on my affected laptop.

Re: Media Keys Don't Work

rjbruintjes
Regular

Actually, I don't know what happened but the issue still persists. Sorry for the false hope!

Re: Media Keys Don't Work

BlackDex
Regular

There is nothing Spotify can do, except maybe for modifying there player name to 0Spotify or something which maybe gets it sorted at the top of the dbus list.

 

When you encounter issues with your media-keys execute the following command and look at the result:

dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames | grep 'org.mpris'

 

It will probably show that there is an other player also active, and possibly with a letter earlier in the alphabet then the S from Spotify.

 

To mitigate this at least for your self you could close this other player or use a tool i created which i posted a few posts back which you can use to bind it to Spotify it self.

 

Re: Media Keys Don't Work

6etacat
Casual Listener

Don't think media keys depend on name order. From my experience, it really only controls the app that started first. A quick fix is to start Spotify after you boot and leave it there. Media keys will always work for Spotify in this case. As you have mentioned, this isn't something the Spotify app can do to remediate. 

Re: Media Keys Don't Work

MadMartian
Music Fan

Excellent tip about looking-up the DBus mpris registry entries.  I usually have the opposite problem.  If I have both Spotify and Clementine running (I use Clementine for certain radio stations not available in Spotify) Spotify responds to the media buttons but not Clementine.  If I close Spotify then Clementine responds to the media buttons.

I was inspired to build on your DBus command, this will yield the process ID as well as the DBus name.  This will make it easier to pin-point the culprit using your process viewer.

DBus Media Player & PID

for qualifiedName in `dbus-send --session --dest=org.freedesktop.DBus --type=method_call --print-reply /org/freedesktop/DBus org.freedesktop.DBus.ListNames | sed -n 's/.*"\(org\.mpris\..*\)"/\1/p'`
do
    printf "$qualifiedName\t"; dbus-send --session --print-reply --dest=org.freedesktop.DBus / org.freedesktop.DBus.GetConnectionUnixProcessID string:$qualifiedName | sed -n 's/^[[:space:]]*uint32 \([0-9]*\)$/\1/p'
done

Example

org.mpris.MediaPlayer2.clementine       24870
org.mpris.MediaPlayer2.spotify  19718
org.mpris.clementine    24870

I can then use System Activity to track-down these processes (screenshot attached).

spotify-clementime-processes.png

Re: Media Keys Don't Work

6etacat
Casual Listener
Have you tried closing spotify and opening it up again? What will your media buttons control now?

Re: Media Keys Don't Work

BlackDex
Regular
In your case i would suggest to try my mpris-control app then. https://github.com/BlackDex/mpris-control/ .
You can then create specific global hotkeys via your desktop tools, gnome, kde etc.. an handle that. I have super+<media-keys> linked to spotify and nothing else. And without super is just normal behavior.
SUGGESTED POSTS