How To Setup Spotify-TUI and Spotifyd With Pulseaudio.

How to be a Linux elitist and play music from your T E R M I N A L

Published: December 18, 2022

Reading Time: 6 minutes

How to set up spotify-TUI with spotifyd and pulseaudio

I was recently looking at bpytop and noticed that Spotify was using around 1GB of memory which seemed incredibly high for an application that only needs to do one thing: play music. After looking around out I found spotify-tui which is a Spotify client for the terminal written in rust. I spent a while tinkering with this and found a lot of the documentation out there was lacking. Specifically the documentation around setting up spotifyd. I eventually got the two working together and have been using it without issue. When playing music, Spotify-TUI uses around 19MB of memory compared to the normal application’s ~800MB.

Prerequisites and Assumptions

I will be walking through how to set up spotify-TUI and spotifyd using pulseaudio as the backend audio driver. I had a lot of problems with alsa (the default device for spotify-TUI). Here are the noteworthy things you will need to follow along:

  • You MUST have a spotify premium account for this to work. Spotify does not allow non-premium users to use the API
  • Debian Linux machine with snap
  • PulseAudio

Spotify-tui Installation

The first step in setting up and configuring spotifyTUI, spotifyd, and pulseaudio is getting all the required software.

1# Install the spotify-tui program
2sudo snap install spt
3# Install pulseaudio
4sudo apt install pulseaudio

Next we need to configure spotify-tui to connect to Spotify’s API.

The documentation provides fairly clear steps:

  1. Go to the spotify dashboard and login.
  2. Click “Create an app”.
  3. Give it a name and a description and click create.
  4. You will need both the Client ID value and the Client Secret.
  5. Click edit settings and under redirect URIs enter: http://localhost:8888/callback.
  6. Click save.
  7. Run spotify-tui in your terminal by typing spt.
  8. Enter your Client ID and Client Secret seen at step 4.
  9. Your browser will open and ask you for permissions. Accept all. .
  10. Done.

Great, you’ve not set up spotify-tui. It will take some time to get used to the controls but after a few days you’ll have no issues. Next we need to install Spotifyd.

Installing an Configuring Spotifyd

Spotifyd is a very lightweight spotify client that is needed to link with spotify-tui. To install it, we first need to grab it from github.

 1# Download the spotifyd tool 
 2git clone
 3# Change into the spotifyd directory
 4cd spotifyd
 5# Compile the tool with the pulse audio features
 6cargo build --release --features "pulseaudio_backend"
 7# Move the compile binary to your path
 8# This needs to be ran with sudo because non-root users do not have 
 9# permissions to write to your path (this is for security reasons)
10sudo cp target/release/spotifyd /usr/bin/

Next we need to create the spotifyd configuration file that allows us to tell spotifyd how to authenticate to spotify as well as some configurations.

1# Make the spotifyd configuration file directory 
2# the `-p` creates all directories needed if they don't exist
3mkdir -p ~/.config/spotifyd/
4# Open the file in vim, you could also use nano if you'd like 
5vim $.config/spotify/spotifyd.conf

This is where you define your configurations. This is mine, you just need to change your username, password, and (optionally) device name.

 2# This is your spotify account name. Not your email
 3username = "<your username>"
 5# Note that this will be a plaintext password. Make sure it is a 
 6# unique password that is not used anywhere else. We will make this 
 7# file only readable by the root user to *help* mitigate the security risk.
 9password = "<your password>"
11backend = "pulseaudio"
13# The device name can't have spaces
14device_name = "spotifyd"
15device_type = "computer"
17# Audio bitrate
18bitrate = 320
20# Create a cache directory but does not use it 
21cache_path = "/home/USER/.cache/spotifyd"
22no_audio_cache = true
24# Set the inital volume of spotify to 100
25initial_volume = "100"
26# My audio was a bit quiet. You can make it a bit louder by chaning the gain
27normalisation_pregain = 10
28zeroconf_port = 4444

Next we should change the file permissions so that it is only readable by our user, and root. We want to do this so that no one can read the file with our password in it besides the root user or someone logged in as our user. Again, it is NEVER best practice to have passwords in configuration files, make sure you understand the risk before doing so.

1# Set the file permissions to not be readable by other users 
2sudo chmod 640 ~/.config/spotifyd/spotifyd.conf

Now that spotifyd is setup, we should create a systemd service so that it will automatically start up. systemd is a (contentious) system and service manager. We can create a file in one of the various systemD look up paths that will be automatically executed at startup. We also can control the systemd process by issuing the command sudo systemctl [status|start|stop|restart] spotifyd.service. Here is how you create a systemd unit.

 1# Create the file and open it
 2vim /etc/systemd/system/spotifyd.service
 4# Copy and paste this. I got this from
 6Description=A spotify playing daemon
14ExecStart=/usr/bin/spotifyd --no-daemon

Next we need to start the service and make sure it starts when we boot our machine.

1# Starts the systemd service 
2sudo systemctl start spotifyd.service
4# Check to make sure it is running 
5sudo systemctl status spotifyd.service 
6# You may see a warning saying "No config file specified".
7# I'm not sure why this happens but it shouldn't matter as it still works 
8# If you know why this is happening, let me know!

That should be everything you need to get your services up and running. Now all you need to do is launch spotify-tui again using the spt command. Make sure you select your device (the device name is the one we defined earlier in the device_name value of spotifyd.conf). To select your device, once inside of spotify-tui, press d and use the arrow keys to select whatever you called your device. The press enter. That is all you need to do. You can now pretend like your an elitist linux user by playing your music from the terminal. :)


Have any questions?

Do you have any questions or comments? Feel free to reach out to me on any of the social platforms ->