Linux command line spotify player

Written by
Date: 2020-04-05 21:50:00 00:00

Introduction

I like to use everything from the terminal when on Linux, just because it is possible, but because of its low use of memory it is also a good idea to run on the terminal anything you can run on it, that is the case of Spotify, there is an official app for Linux but it consumes too much memory.

I will show here two ways to listen to spotify from the Linux command line, each has a different approach.

ncspot

If you want an almost complete spotify player but working on the terminal, you can go for ncspot it uses ncurses, its name comes from ncurses spotify, and you can check its development on github

One of the main reasons to install these kind of apps is because the use an small amount of memory compared with the official Spotify App.

Client Private Memory Shared Memory Total
ncspot 22.1 MiB 24.1 MiB 46.2 MiB
Spotify 407.3 MiB 592.7 MiB 1000.0 MiB

Installation

There are various options to install it, let's see two of them, but before you need to install the dependencies.

sudo apt install libpulse-dev libssl-dev libxcb1-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev

Using snap

sudo snap install ncspot

Using cargo

cargo install ncspot

Using it

The first time you run it, it will ask for your Spotify credentials, after that you will something like this.

ncspot spotify client for linux command line

With the key bindings you can control it, the most useful are:

< and >
Play next and previous track
+ and -
Increase and decrease volume
q
Quits and application

The good

ncspot is almost a full featured spotify client on the Linux terminal, you can play your lists, play albums and your favorite songs, you can add songs to your library and remove them from it, as you can see it has a lot of features.

The bad

I have found just one bad thing, it is not compatible wiht spotify-connect

librespot

librespot is another aproach to listen spotify on Linux using the terminal, it is not a spotify client, it works just like your Alexa Echo Dot, it converts your computer in a smart speaker that you can control from your cell phone.

Installation

To install it, you need to install all dependencies:

sudo apt-get install build-essential libasound2-dev

After that you can install using:

cargo install librespot

Usage

Once installed you have make your computer works as headless speaker, compatible with Spotify-connect, you can use librespot with this command according with its homepage

librespot -n "Librespot-Dell" -b 320 -c ./cache --enable-volume-normalisation --initial-volume 75 --device-type avr

The above command will create a receiver named Librespot, with bitrate set to 320kbps, initial volume at 75%, with volume normalisation enabled, and the device displayed in the app as an Audio/Video Receiver. A folder named cache will be created/used in the current directory, and be used to cache audio data and credentials.

After that, you need to connect your cell phone to the same wifi network that your computer is, and open the spotify app, this will make librespot login and get your credentials as soon as you send the music to it, using spotify connect.

You will see something like this:

spotify connect on Android

Conclusion

There you have two different approaches to use Spotify on the Linux Terminal, and listen to music while using a small amount of memory, I prefer the librespot solution, but that is just me.

As a bonus here is a playlist of one of the best Rod Stewart albums "Great Rock Classics of All Time", but sung by the original artists