A helper for opening spotify urls in a running spotify instance (rather than in a browser), on linux, implemented using clojure and babashka.
Named after the spotify linux client’s spotty support for this feature.
Spotify supports changing the current song via Dbus and spotify uris. So how do
we use that path when a link is clicked in, say, Slack
?
Spotty’s approach is to replace the default desktop application that runs when
handed a url. If the passed url contains spotify.com
, it will convert the url
to a uri, and send the uri to the running spotify client. Otherwise, it will
open the passed url via whatever .desktop entry you prefer (ex:
google-chrome.desktop
, firefox.desktop
).
This might not work for every case - this was developed to see if it would work.
For more on Desktop Entries.
# opens in running Browser instance
spotty https://wiki.archlinux.org/index.php/Desktop_entries
# opens in running Spotify client
spotty https://open.spotify.com/track/7oaEjLP2dTJLJsITbAxTOz
ln -s ~/russmatney/spotty/spotty.clj ~/.local/bin/spotty
In /usr/share/applications/spotty.desktop.
[Desktop Entry]
Version=1.0
Name=Spotty
GenericName=Spotify then Web Browser
Comment=Open Spotify if relevant, Browser otherwise
Exec=/home/russ/.local/bin/spotty %U google-chrome.desktop
Terminal=false
Type=Application
MimeType=x-scheme-handler/http;x-scheme-handler/https;
Note the use of google-chrome.desktop
- the second argument to spotty should
be your intended ‘fallback’ desktop entry.
Set spotty.desktop
as your http/https url handler:
unset BROWSER
xdg-settings set default-web-browser spotty.desktop
xdg-mime query default x-scheme-handler/https
xdg-mime query default x-scheme-handler/http
export BROWSER=/usr/bin/google-chrome-stable
This is used to launch the desktop entry of your choice when the passed url is not a spotify one.
I installed it via `yay -Sy gtk3`.
You’re putting your default browser desktop entry in the Exec line of another…
I’m hoping this mitigated by the `gtk-launch` command, which seems to call the desktop entry the same as xdg-open would have done in the first place.
Sp bash spotify client from streetturtle
https://gist.github.com/streetturtle/fa6258f3ff7b17747ee3
Thanks for this!
Could probably just fire into spotify dbus directly