Running Spotify on the Terminal with spotifyd & spotify-tui

If you like your music, have a Spotify account and use Linux then spotifyd and spotify-tui might be nice alternative to using a heavier GUI client.

spotifyd is a simple daemon service for allowing you to play Spotify on your device, it can even be run on a Raspberry Pi if you want to create your own internet enabled speaker! Unfortunately it requires a Spotify Premium account but it is very simple to setup.

spotify-tui is a simple command line UI for controlling Spotify, you don’t actually have to use it with spotifyd as it can control any of your Spotify enabled devices. This includes playing it “Everywhere”.

Both are written in Rust so can produce binaries for most devices. spotifyd is actually present in the Arch community repositories and spotify-tui is present in the AUR (note the build time for spotify-tui can take quite a while).

Once installed you just need to setup your authentication for both and then you can control and listen to your Spotify on the command line. spotifyd requires your username and password whereas spotify-tui uses a token to access your Spotify account. The command for spotify-tui is actually spt.

If you don’t like spotify-tui you can control it using something like playerctl since spotifyd registers itself on the D-BUS interface. This actually allows you to potentially bind shortcut keys to control your music since you can write a simple command like:

playerctl -p spotifyd play-pause

To pause and resume your music. In fact with playerctl you can omit the player option and let it use the last player in use allowing you to control both Spotify and other media players.
Additionally playerctl let’s you get the metadata from your player so you can do all sorts with this e.g.

playerctl metadata --format "Now playing: {{ artist }} - {{ album }} - {{ title }}"

And because spotifyd is separate to spotify-tui you also don’t need to keep spotify-tui running.


Comment posting is disabled, please email or discuss on another platform.

Name: Lyndon
Date: March 10th, 2021 19:43

So if you use i3 here’s some bindings for the media buttons on various keyboards using playerctl:

bindsym XF86AudioPlay exec --no-startup-id playerctl play-pause
bindsym XF86AudioPause exec --no-startup-id playerctl pause
bindsym XF86AudioStop exec --no-startup-id playerctl stop
bindsym XF86AudioNext exec --no-startup-id playerctl next
bindsym XF86AudioPrev exec --no-startup-id playerctl previous

I looked at doing the volume buttons but playerctl wasn’t playing nice.