Skip to content

russmatney/spotty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

Spotty

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.

How does this work?

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.

Examples

# 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

Installation

Symlink to somewhere on your path

ln -s ~/russmatney/spotty/spotty.clj ~/.local/bin/spotty

Create a Desktop Entry for 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

Dependencies

gtk3 (for gtk-launch)

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`.

Drawbacks

Convoluted setup, unless you’re already a linux wizard.

You’re putting your default browser desktop entry in the Exec line of another…

Unknown, unintended consequences of replacing your default browser for xdg-open

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.

Assumes both the browser and spotify client are already running

Inspired by

Sp bash spotify client from streetturtle

https://gist.github.com/streetturtle/fa6258f3ff7b17747ee3

Thanks for this!

Future work

[X] remove `sp` dependency

Could probably just fire into spotify dbus directly

[ ] clean up output

[ ] add reasonable help text

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages