A Rust CLI for controlling Spotify playback and queue management via the Spotify Web API.
- Control playback:
pause,resume,next,prev - Search and queue tracks with
play - Show the current queue with
show - Add the current track to liked songs with
add - Set volume with
vol - Transfer playback to a phone device with
phone(hardcoded device id)
- Rust toolchain (edition 2021)
- A Spotify account and a Spotify Developer app
- Spotify app redirect URI set to
http://localhost:8080 - Linux: install
libxdodevelopment package (required byenigo)
-
Create a Spotify Developer app and note the Client ID and Client Secret.
-
Update the credentials in
src/api_requests/getsessiontoken.rs:client_idclient_secret
-
Create the token directory used by the app:
mkdir -p database/tokens
-
Build the CLI:
cargo build --release
Run commands with cargo run while developing, or execute the built binary:
cargo run -- <command>
# or
./target/release/spotify <command>next(optional--count/-c <n>) — skip forwardprev— skip backwardpause— pause playbackresume— resume playbackreplay— re-queue the current trackplay [what] [who]— search and queue tracks by title and/or artistshow— show queued tracksadd— add the current track to liked songsvol [val]— show or set volume (0-100)phone— transfer playback to the hardcoded phone device id
- Tokens are stored in
database/tokens/with filenames likeadmin_access_token.txtandadmin_refresh_token.txt. - If you want to change the client name used for token storage, update
get_client()insrc/api_requests/getsessiontoken.rs. - The
phonecommand uses a fixed device id insrc/api_requests/playback/device.rs; update it for your device. - Playback control requires an active Spotify device; the CLI attempts to open Spotify on macOS using AppleScript.
cargo testorcargo buildfails withunable to find library -lxdoon Linux: install thelibxdodevelopment package (for example,libxdo-dev). README.md
copilot/update-readme-file Send message What would you like to do next?