Skip to content

Spotify in the terminal

I set up Spotify in the terminal, following this blog post. This documents my (MacOS) setup.


Warning! I noticed that tracks played in this way don't show up in Recently Played on Spotify (in the official client, in Spotify TUI, or via the API), so I worried that artists whose music I played weren't getting paid for it. When I played from the Spotify official client, but connected to Spotifyd as a device via Spotify Connect, then tracks did show up. So I abandoned Spotify TUI (for playing track at least, it's still useful for other bits and pieces), and am now playing to Spotifyd only via the official client(s).

Install spotifyd

The spotifyd client can be installed by Homebrew:

brew install spotifyd

It needs a config file with (at least) credentials:

mkdir ~/.config/spotifyd
vi ~/.config/spotifyd/spotifyd.conf

I pasted the contents from then edited accordingly: as a minimum my username and password for Spotify (more specifically, a command that yields the password so it isn't stored in plain text). A MacOS value is recommended for several of the settings, which I used, and the rest I commented out, since sensible defaults are used. Naming the device is useful so it can easily be found later:

# The name that gets displayed under the connect tab on
# official clients.
device_name = "device_name_in_spotify_connect"

Then start the client:

spotifyd --no-daemon

You can start it as a background service so it will restart at login with:

brew services start spotifyd

Once the service is running, it can be used as a client via Spotify Connect; e.g. from an official Spotify client on the same network

(I haven't bothered to change the name from the placeholder value yet!)

Setting up Spotify TUI

The text user interface to Spotify is installed with:

brew install spotify-tui

The app needs to be registered on the Spotify Dashboard to get a Client ID and Secret for using the API. On first executing Spotify TUI (by running spt), enter these and the default port number (8888), authorise via the web page that comes up, and you're away.

To set the device, run spt and press the d shortcut key to see the list of Spotify Connect devices available

As well as running spt interactively you can play music via options, e.g.

spt play --name "St. Christopher is Coming Home" --track

etc. Check the docs for examples: