A simple tool to control spotify from the command line. Based on rspotify.
SpotifyCtl has few commmands:
get: Display the currently playing track or episode.previous: Restart the current track or skip to the previous track.next: Skip to the next track.play-pause: Pause or resume playback.
SpotifyCtl is written in Rust. First, one need to Install a rust toolchain. And then run:
cargo install --path .
- One need to create a spotify app on the dedicated page.
- You will get a
Client Idand aClient Secret. Note them down. - Edit the settings of your app to add a
Redirect URI. I suggest usinghttps://localhost:8888/callback. This URI do not need to be accessible. - Add any user email that will be able to use
spotifyctl. - Export the following environment variables with the values noted down:
export RSPOTIFY_CLIENT_ID=ef0fbc0adc633de52214e7a211a13310
export RSPOTIFY_CLIENT_SECRET=08c77cdf9a8df31ffac2cd03eff0a748
export RSPOTIFY_REDIRECT_URI=https://localhost:8888/callback- Run
spotifyctl getin a terminal. This should start a browser when you will to let your spotify user accept to connect to your new spotify app. - You will redirected to an invalid webpage. Note that URL and past it to the
terminal where you ran
spotifyctl get. - This will occur only once since
spotifyctlwill store a renewable token on the disk and you will not have to authenticate using a browser again. - Run any other
spotifyctlcommand whenever you want, but always with the previously defined environment variables.