Skip to content

Instantly share code, notes, and snippets.

@lyrixx
Last active March 17, 2020 16:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lyrixx/c3610cc48059cd5e558a5d0b9df385ea to your computer and use it in GitHub Desktop.
Save lyrixx/c3610cc48059cd5e558a5d0b9df385ea to your computer and use it in GitHub Desktop.
Spotify does not handle Media Keys

Debug media keys and Spotify

TL;DR: There is a bug in gnome that have been fixed in 3.3. But you can temporary fix this issue with: pkill gsd-media-keys

Let's Debug

  1. We check logs

    journalctl -f
    

    =>

    Jan 16 14:37:43 gregoire gsd-media-keys[2670]: Error calling method GDBus.Error:org.freedesktop.DBus.Error.ServiceUnknown: The name org.mpris.MediaPlayer2.chromium.instance8878 was not provided by any .service files
    

    It looks like it comming from dbus

  2. Check dbus logs

    dbus-monitor
    

    Then use your media keys

    =>

    signal time=1579184803.311666 sender=:1.21 -> destination=:1.56 serial=82274 path=/org/gnome/Shell; interface=org.gnome.Shell; member=AcceleratorActivated
    uint32 1713
    array [
        dict entry(
            string "device-id"
            variant             uint32 3
        )
        dict entry(
            string "timestamp"
            variant             uint32 222074642
        )
        dict entry(
            string "action-mode"
            variant             uint32 1
        )
    ]
    method call time=1579184803.313383 sender=:1.56 -> destination=org.mpris.MediaPlayer2.chromium.instance8878 serial=586 path=/org/mpris/MediaPlayer2; interface=org.mpris.MediaPlayer2.Player; member=PlayPause
    error time=1579184803.313423 sender=org.freedesktop.DBus -> destination=:1.56 error_name=org.freedesktop.DBus.Error.ServiceUnknown reply_serial=586
    string "The name org.mpris.MediaPlayer2.chromium.instance8878 was not provided by any .service files"
    

    It looks like a processus sender=:1.21 receive the event (media key pressed), and sent it to another processus destination=:1.56

    Then this processus sender=:1.56 sent the PlayPause event to another processus org.mpris.MediaPlayer2.chromium.instance8878

    But according to the error, this processus does not exists.

  3. Try if Spotify understand the event correctly

    The following command should Play/Pause Spotify

    dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause
    
  4. Who is sender=:1.21 and sender=:1.56

    I looks like the first sender is doing right its job, but second does some bullshit.

    d-feet is a useful GUI software to get who it is (and try few things).

    Just type 1.21 or 1.56 in the Session Bus > search to know how it is

    • 1.21 is gnome-shell. Legit, gnome-shell handles my MediaKeys
    • 1.56 is /usr/lib/gnome-settings-daemon/gsd-media-keys

    So it looks like we have found our culprit !

  5. restart gsd-media-keys

    Let's try to retry this little daemon that should forward Media Keys press to the right processus

    ps aux | grep gsd-media-keys
    pkill gsd-media-keys
    ps aux | grep gsd-media-keys
    # The process should have a new PID
    

Some resources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment