Unified command-line Spotify controller with timed sessions
Control Spotify playback through intelligent queuing, contextual listening modes, and timed sessions. Features automatic background server and history tracking.
cue provides smart Spotify control from the command line with timed sessions, automatic background server, and pre-configured listening modes.
cue requires Spotify Premium and API credentials:
http://localhost:8080/callback to Redirect URIsOn first use, cue opens a browser for Spotify authorization:
Python 3.8+Spotify Premium - Required for playback controlclick, requests, flask, spotipy
cue is configured through environment variables and config files in ~/.cue/.
| Option | Type | Default | Description |
|---|---|---|---|
SPOTIFY_CLIENT_ID | string | (required) | Spotify API client ID from developer dashboard |
SPOTIFY_CLIENT_SECRET | string | (required) | Spotify API client secret |
SPOTIFY_REDIRECT_URI | URL | http://localhost:8080/callback | OAuth redirect URI |
CUE_SERVER_HOST | string | 0.0.0.0 | Server bind address |
CUE_SERVER_PORT | integer | 8080 | Server port |
CUE_CLIENT_SERVER_URL | URL | http://localhost:8080 | Target server URL |
CUE_CLIENT_TIMEOUT | seconds | 30 | Request timeout |
CUE_NO_AUTO_SERVER | boolean | false | Disable auto-server startup |
Background server settings:
| Option | Type | Default | Description |
|---|---|---|---|
host | string | 0.0.0.0 | Server bind address |
port | integer | 8080 | Server listen port |
timeout | seconds | 30 | Request timeout |
debug | boolean | false | Enable debug logging |
| Option | Type | Default | Description |
|---|---|---|---|
default_duration | string | full | Default playback duration |
max_search_results | integer | 50 | Maximum search results |
queue_position_limit | integer | 100 | Maximum queue size |
token_refresh_buffer | seconds | 600 | Refresh token 10 min early |
~/.cue/client.json - Client configuration (server_url, timeout)~/.cue/modes.json - Custom mode definitions~/.cue/cue.db - SQLite database for sessions and queue~/.cue/server.pid - Server process ID~/.cue/server.log - Server output logcue is a unified command-line Spotify controller that enables smart playback management through timed sessions, intelligent queuing, and contextual listening modes.
cue uses Spotify's OAuth2 flow for secure authentication.
On first use, cue opens a browser for Spotify authorization:
user-modify-playback-state - Play, pause, skipuser-read-playback-state - Get current playbackuser-read-recently-played - History trackingTokens are automatically managed:
.spotify_cache filecue supports multiple playback modes with optional duration limits:
Specify how long to play with duration strings:
full - Complete track (default)30s - 30 seconds15m - 15 minutes2h - 2 hours1d - 1 dayBuild up a playlist of tracks to play:
Pre-configured modes for different activities with optimized audio features:
Low energy, instrumental, moderate tempo. For concentration.
High energy, danceable, upbeat. For social events.
High BPM, energetic, motivating. For exercise.
Minimal energy, slow tempo, quiet. For winding down.
Positive vibes, gentle energy. For waking up.
Relaxed, medium energy, easy listening.
Custom modes can be defined in ~/.cue/modes.json.
Control playback across all your Spotify Connect devices:
cue uses a client-server architecture where the CLI communicates with a background Flask server that manages Spotify state.
cue/
├── __init__.py # Package metadata
├── __main__.py # Module entry point
├── main.py # Smart dispatcher
├── cli/
│ ├── commands.py # Click CLI definitions
│ └── client.py # HTTP client
├── core/
│ ├── config.py # Configuration
│ ├── spotify.py # Spotify API wrapper
│ ├── database.py # SQLite storage
│ ├── models.py # Data models
│ ├── duration.py # Duration parsing
│ └── formatting.py # Display formatting
└── server/
├── app.py # Flask application
├── handlers.py # Request handlers
├── session.py # Session manager
├── modes.py # Mode definitions
└── queue.py # Queue processing Clean separation between CLI, core services, and server layers:
Click-based command interface with HTTP client:
Shared functionality used by both CLI and server:
Flask-based REST API for playback management:
Request flow from CLI to Spotify:
cue play "song" SQLite database stores sessions and queue:
-- Sessions table CREATE TABLE sessions ( id INTEGER PRIMARY KEY, track_name TEXT, track_uri TEXT, start_time DATETIME, end_time DATETIME, duration INTEGER, status TEXT -- playing, completed, stopped ); -- Queue table CREATE TABLE queue ( id INTEGER PRIMARY KEY, track_name TEXT, track_uri TEXT, duration INTEGER, position INTEGER, status TEXT -- pending, playing, completed );
Complete command-line interface reference for cue.
| Option | Type | Default | Description |
|---|---|---|---|
cue play <query> [duration] | command | - | Play track with optional duration |
cue play album <name> [duration] | command | - | Play an album |
cue play artist <name> [duration] | command | - | Play artist top tracks |
cue play playlist <name> [duration] | command | - | Play a playlist |
cue play genre <name> [duration] | command | - | Play genre-based recommendations |
cue stop | command | - | Stop current playback |
cue skip | command | - | Skip to next track |
cue status | command | - | Show playback status |
| Option | Type | Default | Description |
|---|---|---|---|
cue queue add <query> [duration] | command | - | Add track to queue |
cue queue list | command | - | Show queued items |
cue queue clear | command | - | Clear all queue items |
| Option | Type | Default | Description |
|---|---|---|---|
cue focus [duration] | command | 2h | Focus mode - low energy, instrumental |
cue party [duration] | command | 3h | Party mode - high energy, danceable |
cue workout [duration] | command | 1h | Workout mode - high BPM, energetic |
cue sleep [duration] | command | 45m | Sleep mode - minimal energy, slow tempo |
cue morning [duration] | command | 30m | Morning mode - positive vibes |
cue chill [duration] | command | 1h | Chill mode - relaxed |
cue mode list | command | - | List all modes |
cue mode start <name> [duration] | command | - | Start specific mode |
cue mode stop | command | - | Stop current mode |
| Option | Type | Default | Description |
|---|---|---|---|
cue volume set <0-100> | command | - | Set volume level |
cue volume get | command | - | Get current volume |
cue vol <0-100> | command | - | Quick volume set |
cue louder [amount] | command | +10 | Increase volume |
cue quieter [amount] | command | -10 | Decrease volume |
cue mute | command | - | Mute (set volume 0) |
| Option | Type | Default | Description |
|---|---|---|---|
cue device list | command | - | List available devices |
cue device switch <name> | command | - | Switch to device |
| Option | Type | Default | Description |
|---|---|---|---|
cue health | command | - | Check server and Spotify connection |
cue --server | command | - | Start server mode |
cue --server-stop | command | - | Stop background server |
cue --server-status | command | - | Check server status |
cue --server-logs | command | - | View server logs |
| Option | Type | Default | Description |
|---|---|---|---|
cue history | command | - | Show playback history |
cue history -n <num> | command | 20 | Limit history items |
cue history --today | command | - | Today only |
cue history --this-week | command | - | This week only |
cue history -c | command | - | Include Spotify history |
Common issues and solutions when using cue.
Problem: Error about missing credentials.
Solution: Set environment variables:
Problem: First run fails authentication.
Solution: Run any command and complete browser OAuth flow.
Ensure http://localhost:8080/callback is in your
Spotify app's redirect URIs.
Problem: Can't play - no active devices.
Solution:
cue device list to verifyProblem: Commands fail with connection errors.
Solution: Check server status:
Problem: Search returns no results.
Solutions:
"Song Name Artist"Problem: Queue items don't play automatically.
Solution:
cue status for active sessioncue queue listcue --server-logsProblem: Playback control fails.
Cause: Spotify Premium is required for playback control API. Free accounts can only read playback state, not control it.
If you prefer to manage the server manually:
cue --helpcue play --help