Control Spotify Connect with your Mac's Media Keys

Hi! I use the Spotify Web Player to listen to music all the time. I also use Spotify Speakers like the Google Home, and embedded web players built on the Spotify Web Playback SDK all the time. I found I was often looking for the right play/pause/next/previous control (or keeping a Spotify client open all the time) when working at my computer to control the music. Then I found the Simple HotKey Daemon, which lets me bind scripts to keys on my Mac, and decided to use it to hook my media keys to Spotify Connect, using the Spotify Connect Web APIs. And you can too!

Step One!

Register yourself a client id in the Spotify for Developers Dashboard. Make a note of the client id and client secret, and insert them into a JSON file at ~/.config/spotify_client_creds.json like this:

{
  "id":"your client id",
  "secret":"your client secret"
}

Step Two!

Install the spotify-control CLI. This is how SKHD will trigger Spotify Connect actions.

$ npm install --global @hughrawlinson/spotify-control

Step Three!

Log in to the spotify-control cli:

$ spotify-control login

This will log the cli into your Spotify account.

Step Four!

Configure shkd by pasting the following lines into your ~/.shkdrc file:

play : spotify-control toggle
fast : spotify-control next
rewind : spotify-control previous

Then you should install shkd - you can use homebrew:

$ brew install koekeishiya/formulae/skhd
$ brew services start skhd

And you're all set!

Tweet me if you have any issues - @hughrawlinson