Introduction
Spotifyd is an open-source Spotify client for Unix-like systems. It runs in the background as a daemon and allows you to control Spotify using terminal-based clients like spotify-tui. In this guide, we'll walk you through the process of installing and setting up spotifyd on macOS.
Prerequisites
- A Spotify Premium account.
01Install Spotifyd
First, we'll install spotifyd using Homebrew. Open a Terminal window and type the following command:
$ brew install spotifydHomebrew will download and install spotifyd.
02Create a configuration file
Next, we'll create a configuration file for spotifyd that stores your Spotify login details and other settings. Use the following commands:
mkdir -p ~/.config/spotifyd
touch ~/.config/spotifyd/spotifyd.confThis will create a new file at ~/.config/spotifyd/spotifyd.conf.
03Edit the configuration file
Now we'll edit the configuration file. You can use any text editor you like; in this example, we'll use nano:
$ nano ~/.config/spotifyd/spotifyd.confThis will open the file in the nano text editor. Copy and paste the following into the file:
[global]
username = "<your-spotify-username>"
password = "<your-spotify-password>"
backend = "portaudio"
device_name = "spotifyd"
bitrate = 320Replace <your-spotify-username> and <your-spotify-password> with your Spotify username and password.
Then press Ctrl+X to exit nano, press Y to confirm that you want to save the file, and then press Enter to confirm the filename.
04Run Spotifyd
You're now ready to run spotifyd! Type the following command in your Terminal window:
$ spotifydspotifyd will now run in the background. You should be able to see it as an available device in your Spotify client.
05Control Spotify from the Terminal
To control Spotify from the terminal, you can use a tool like spotify-tui. Here's how to install it:
$ brew install spotify-tuiBefore running spotify-tui, make sure to set up the necessary environment variables. Follow the instructions in the spotify-tui readme for how to do this.
Once you've set up spotify-tui, you can run it with the following command:
$ sptYou can now control Spotify from the terminal!
Welcome to the new era of uninterrupted coding sessions. No more switching apps to control your music - your terminal has got it covered. Let your favourite tracks fuel your productivity as we move towards our midnight mark in this 24-article series.
Remember, the more you use these commands, the more they'll become second nature, bringing you closer to terminal mastery.