[Guide] Play Spotify links in running client

Reply

[Guide] Play Spotify links in running client

epinephrine
Regular

Hi,

After combining a few ideas, I got my firefox to open spotify links à la 

https://open.spotify.com/track/4kLyPZvYQE2N1K2rFQ3e6a?si=sLbFkVGvS6izC2-6J74iZQ

directly in my running Linux Spotify client. Here's how:

 

1. Install Greasemonkey (Firefox) or Tampermonkey (Chrome) and then this script.

I modified it to not even open the web-player but directly redirect to spotify by adding the line

// @run-at      document-start

in the header section of the script. I sent a request to the author to incorporate that change.

 

2. Create a new spotify URI handler at ~/.local/share/applications/spotify-open.desktop with the content

[Desktop Entry]
Type=Application
Name=Open in Spotify
GenericName=Music Player
Icon=spotify-client
Exec=qdbus org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri %U
Terminal=false
MimeType=x-scheme-handler/spotify;
Categories=Audio;Music;Player;AudioVideo;
StartupWMClass=spotify

Make sure you have qdbus installed. On Arch Linux, this is found in package qt5-tools.

 

Now if you click on any open.spotify.com link, it will automatically play in your client.

 

Cheers,

Sebastian

1 Reply
Highlighted

Re: [Guide] Play Spotify links in running client

epinephrine
Regular

An alternative to qdbus is dbus-send, which is probably more commonly installed:

dbus-send --type=method_call --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.OpenUri string:'spotify:track:1WNPappMd13lY5o9POZ4gU'

replace spotify:track:... with %U for use in the desktop entry file.

SUGGESTED POSTS