📻 spotify-cmd v0.9.11
spotify-cmd is a Spotify client that allows controlling the playback of albums, playlists, and followed artists from a user's library (based on names or Spotify URIs) and individual tracks (based solely on Spotify URIs). The application is intended for use with spotifyd, but it works with any Spotify-enabled device.
Installation
Ensure you have Python 3 installed. Package is available on PyPi: https://pypi.org/project/spotify-cmd/. Install it using pip3:
pip3 install spotify-cmd
On first use, the CLI, terminal UI, or daemon creates a private configuration template and prints setup instructions. You can also prepare it explicitly:
spotify-cmd init
# Edit the file printed by init; fill in client_id and client_secret.
spotify-cmd config check
spotify-cmd auth
spotify-cmd-daemon
spotify-cmd-ui
Create an app in the Spotify Developer Dashboard
and register http://127.0.0.1:8888/callback as its redirect URI.
Spotify requires an explicit loopback IP rather than localhost
(redirect URI requirements).
For a headless host, use spotify-cmd auth --no-browser and paste the full
redirect URL when prompted. The browser may show a connection error when the
callback is on another machine; copy its URL to the terminal on the host.
init never overwrites an existing file. Newly created configuration files
have permissions 0600. config check validates local settings without
contacting Spotify or printing credentials. Authorization stores the token
in cache/token-cache next to the configuration. Restart the daemon after
editing its settings. Help and version commands do not create configuration.
Debian/Ubuntu (apt)
curl -fsSL https://maciej-ciemborowicz.eu/apt/spotify-cmd.gpg | sudo gpg --dearmor -o /usr/share/keyrings/spotify-cmd-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/spotify-cmd-archive-keyring.gpg] https://maciej-ciemborowicz.eu/apt ./" | sudo tee /etc/apt/sources.list.d/spotify-cmd.list
sudo apt update
sudo apt install spotify-cmd
The apt installer creates a service configuration template at
/var/lib/spotify-cmd/.config/spotify-cmd/config.ini without overwriting an
existing file. Fill in the Spotify credentials, then authorize as the service
user so the daemon can read its token:
sudo -u spotify-cmd spotify-cmd config check
sudo -u spotify-cmd spotify-cmd auth --no-browser
sudo systemctl restart spotify-cmd
sudo systemctl status spotify-cmd --no-pager
The systemd service skips startup while configuration is incomplete.
The CLI and TUI only need the socket settings; they do not need access to the
service user's credentials. For a separate client configuration, run
spotify-cmd init as your user and set socket_path = /run/spotify-cmd/spotify-cmd.sock.
If you want to run the client as a regular user (for example pi), add it to the spotify-cmd group so it can access the daemon socket:
sudo usermod -aG spotify-cmd <user>
Headless spotifyd (Raspberry Pi, servers)
When using spotifyd on headless hosts, run it in the foreground under systemd and disable MPRIS to avoid DBus/X11 issues:
[global]
use_mpris = false
Configuration
User configuration is created at ~/.config/spotify-cmd/config.ini.
Set SPOTIFY_CMD_CONFIG to select an explicit file (also used by init);
an explicit missing file never falls back to another configuration.
Otherwise the search order is the user file, the apt service file, then
/etc/spotify-cmd/config.ini. Below is an example for the apt service:
[SPOTIFY]
client_id = your_client_id
client_secret = your_client_secret
# Optional; omit to use the active device:
# device_name = your_device_name
redirect_uri = http://127.0.0.1:8888/callback
[SPOTIFY_CMD_DAEMON]
socket_path = /run/spotify-cmd/spotify-cmd.sock
socket_buffer_size = 1024
- client_id, client_secret are required. Obtain these by creating an app at the Spotify Developer Dashboard.
- device_name is optional. If set,
spotify-cmd-daemonwill force to use it even if another is active; if omitted, it uses the current active device. - redirect_uri is used for Spotify authentication. If not set, it defaults to 'http://127.0.0.1:8888/callback'. Existing explicit values are preserved; update both the file and Spotify app settings if migrating from localhost.
- socket_path specifies the Unix socket path for the daemon. Defaults to '/run/spotify-cmd/spotify-cmd.sock' on Linux and '/tmp/spotify-cmd-daemon.sock' on other systems.
- socket_buffer_size defines the buffer size for socket communication. Defaults to 1024.
New user templates explicitly use /tmp/spotify-cmd-<uid>.sock, writable
without systemd on Linux and macOS. Service templates use
/run/spotify-cmd/spotify-cmd.sock. Existing socket settings are preserved;
CLI and daemon must use the same socket path.
Playback device
spotify-cmd controls a Spotify Connect device; it does not play audio itself. Choose one of these options.
Option 1: spotifyd
Run spotifyd on the machine that should play music, then set its Spotify Connect device name in config.ini:
[SPOTIFY]
device_name = My spotifyd
This is the suitable option for headless machines and dedicated audio devices. For a headless systemd service, see the spotifyd instructions above.
Option 2: Official Spotify app
Open the official Spotify desktop, mobile, or web app and make it the active playback device in Spotify Connect. Leave device_name unset to let spotify-cmd use the active device, or set it to the exact name displayed by the Spotify app:
[SPOTIFY]
device_name = MacBook Pro
The official app must be open and visible as a Spotify Connect device before sending a playback command. If another device is active, selecting device_name makes spotify-cmd transfer playback to that named device.
Commands
spotify-cmd offers the following commands:
get playlists: Lists the user's playlists.get albums: Lists the user's albums.get artists: Lists the user's followed artists.play playlist <name>,play album <name>,play artist <name>,play uri <spotify_uri>: Plays a specific playlist, album, followed artist, or resource by Spotify URI.play,pause,next,previous: Controls playback.set shuffle <on|off>: Toggles shuffle mode.set volume <0-100>: Sets the volume level.find <search_type> <query>: Searches for items on Spotify. Acceptable search types arealbum,artist,playlist,track,episode, andshow.version: Prints the installedspotify-cmdversion.
Output Format
Select output format using the --format flag:
--format text: Plain text output (default).--format json: Output in JSON format.--format verbose: Verbose text information.
Usage Examples
spotify-cmd get albums
spotify-cmd get playlists
spotify-cmd get artists
spotify-cmd play album "Listening Tree"
spotify-cmd play artist "Nils Frahm"
spotify-cmd play uri spotify:album:5zKTfU3vyuZfLgtYRfJyza
spotify-cmd find artist "Nils Frahm"
Terminal UI
Run spotify-cmd-ui to browse albums, playlists, followed artists, and the active Spotify queue. Use 1, 2, 3, and 4 to change views, arrow keys to select an item, and Enter to play it. In Artists, Enter opens the selected artist’s albums (including EPs and singles); Enter on an album starts playback. Left returns from the album list to artists. Selecting the Artists tab always opens the artist list. Left/right seek during playback. Unavailable tracks are skipped when selecting a track for playback. Space toggles play/pause, s stops playback, and h toggles shuffle. The UI receives state events from the daemon, so changes made through any client appear automatically.
For Developers
Developers can create interfaces for spotify-cmd-daemon using /run/spotify-cmd/spotify-cmd.sock (Linux) or /tmp/spotify-cmd-daemon.sock (other systems). Socket handling and data format details are in the ./src/common directory (there is no documentation).
Test coverage
Install development dependencies and enable the Git hook:
pip install -e '.[dev]'
pre-commit install
Every commit runs the test suite with coverage for src. A commit passes only with 100% coverage. Run the same check manually with:
python -m coverage run -m pytest
python -m coverage report
The published-package smoke test uses PyPI and a new virtual environment. Run it explicitly when validating a release:
python -m pytest -m pypi
Daemon helper:
spotify-cmd-daemon --versionprints the installed daemon version.
Planned Features and Upcoming Development
Displaying tracks from specific albums or playlists.[Done in 0.1.22]MPRIS D-Bus interface support to reduce server queries.[Done in 0.1.22][Done in 0.1.22]spotify-cmd-ui: A ncurses-based UI for track display and control, working with the same daemon.Search functionality.[Done in 0.1.4]Support for other resource types like artists.[Done]Config instructions after installation / creation of default config.[Done]
License
This project is licensed under the terms of the GNU General Public License. Detailed information can be found in the LICENSE.md file.
Author
Project created by Maciej Ciemborowicz.
Metadata
Release files for spotify-cmd 0.9.11
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| spotify_cmd-0.9.11.tar.gz | 81.8 kB | Without provenance | Details for spotify_cmd-0.9.11.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| spotify_cmd-0.9.11-py3-none-any.whl | Python 3 | none | any | Details for spotify_cmd-0.9.11-py3-none-any.whl |
Total release size: 147.0 kB
Release files / spotify_cmd-0.9.11.tar.gz
| Download URL | spotify_cmd-0.9.11.tar.gz |
|---|---|
| Size | 81.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c90b97dafe774d4e2b5c0dbe4b9cc9160abd970de1f7d78db2e0d31198e26e0a
|
|
BLAKE2b-256 checksum How to use checksums |
8def3209008ad0fbc27d3328f3b980a30204b64363e2028c3976344cad55c97a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Release files / spotify_cmd-0.9.11-py3-none-any.whl
| Download URL | spotify_cmd-0.9.11-py3-none-any.whl |
|---|---|
| Size | 65.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
709f234a434fb0a9b7d1cac0ad44cd2ba1e4975e253ec9064be3cffeddec29fe
|
|
BLAKE2b-256 checksum How to use checksums |
355391b1f46ed52dc950e32f40050dc0802c2016032ec42f4b5ba6080e94f4a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.4
|
Security for spotify-cmd 0.9.11
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.