Automatically view song lyrics as you listen
Tutorial – Lyrics-in-terminal
Whether you listen to music on Spotify or a classic audio player like Rhythmbox, Lollypop, or Audacious, a tool named Lyrics-in-terminal will let you read the lyrics for the track you are currently playing.
In today's very challenging times, there are many artists who write expressive, interesting, and relevant lyrics. Whether it's hip-hop, pop, or folk music, you'll find many artists in recent years who definitely have something to say.
However, it is often not easy for the listener to hear exactly what an artist is saying or singing, or to follow along quickly enough – consider for example, Eminem's double-time rap. Regardless of your taste in music, for many songs you might wish you had a simple option for displaying the lyrics, so you can follow along without having to search for the lyrics on the web time and time again. Some players do offer the ability to display the lyrics for the track currently playing, but even better, the Lyrics-in-terminal [1] program can retrofit this feature for virtually any player.
Installation
Currently you will not find the program in the package sources of the common distributions. Users of Arch Linux and its derivatives have the easiest approach to installing the application: Just download the package lyrics-in-terminal from the Arch User Repository (AUR) onto your system. If you are working with a different distribution, use the pip Python package manager instead, and then run the commands from Listing 1 to install the program on Debian or Ubuntu.
Listing 1
Installation
$ sudo apt install python3-pip $ pip install lyrics-in-terminal
The package manager installs the program into ~/.local/bin/
. However, the shell only adds this directory to the PATH
environment variable if the directory already exists at login time. For the program's lyrics
command to work, you may need to log out and log back in again. If the system still does not find the command, check the ~/.profile
in your home directory and append the lines from Listing 2. After logging out and back on again, the shell command should work.
Listing 2
~/.profile
[...] # set PATH so it includes user's # private bin if it exists if [ -d "$HOME/.local/bin" ]; then PATH="$HOME/.local/bin:$PATH" fi
Lyrics in the Terminal
By default, Lyrics-in-terminal automatically connects to Spotify. You just need to launch the program in a terminal window using the lyrics
command to play any song with the official Spotify client (Figure 1). A short while later, the song lyrics will appear in the terminal window; you do not need a commercial premium account. In the header, you will also see the name of the song, the artist, and below it the album title. If the length of the lyrics exceeds the space in the terminal, you can scroll through the contents with the arrow keys.
In our test, Lyrics-in-terminal worked better than the feature included in Spotify's Android client (the PC variant of the client does not offer this option as of yet). The display in the Android app only provides results for really well-known artists, while Lyrics-in-terminal had no problem identifying salsa from the Caribbean, chansons from France, fado from Portugal, or even Deutschrap (German hip hop). The program only showed a lyrics not found message for instrumentals or acoustic techno tracks – no surprises there.
Under the hood, Lyrics-in-terminal does not use its own database, but accesses the freely available data from AZLyrics [2]. This project has been collecting song lyrics for years and legitimately licensing them from record labels. There is no danger that the texts will disappear off the web overnight. If lyrics are missing or incorrect, the community can add the data via the service's portal.
Not Only Spotify
Now, not every user uses Spotify to play music. No problem: Lyrics-in-terminal does not tap the data about the song currently playing from the player, but via the native D-Bus and the Media Player Remote Interfacing Specification (MPRIS) [3] – a feature that most media players on Linux support. For example, the desktop environments use the technology to control the player's playback via widgets or to display information about the current song.
You can specify which media players Lyrics-in-terminal should now listen out for via an option attached to the call. The lyrics
command links with Spotify as described, while lyrics rhythmbox
links with the Gnome desktop's Rhythmbox media player. The connection works with any media player that can be controlled via D-Bus/MPRIS – that is, with just about any music player on Linux. We tested VLC, Audacious, Lollypop (Figure 2), and the still quite young Gnome Music player.

The only problem here is the correct spelling: You have to write the options rhythmbox
or vlc
in lowercase. Lollypop
, on the other hand, must start with an uppercase letter, and for Gnome Music you must specify the D-Bus name org.gnome.Music
. Otherwise, the program thinks that the desired player would not run (Listing 3).
Listing 3
Lyrics-in-terminal
$ lyrics $ lyrics rhythmbox $ lyrics vlc $ lyrics Lollypop $ lyrics org.gnome.Music
If linking to the desired player does not work right away, you need to check whether you first have to enable support for MPRIS in the player itself. Then experiment with the different spellings if necessary.
As a tip, to avoid the need to specify the audio player as an option, it is a good idea to create an alias for the lyrics
command. To do this, edit the shell's configuration, which is usually the ~/.bashrc
file, and add an entry such as:
alias lyrics='lyrics Lollypop'
After restarting the terminal program, the requirement to specify your preferred player is then dropped.
You can determine the D-Bus name quite easily using a D-Bus debugger like D-Feet [4]. This program is included in the official package sources of most distributions. After launching the application, first switch to the Session Bus in the header of the window and then enter the name of the player in the search field in the left sidebar. The name then appears as a search result; on the right in the display area, the name can then also be copied and pasted to the clipboard (Figure 3).
Buy this article as PDF
(incl. VAT)
Buy Linux Magazine
Direct Download
Read full article as PDF:
Price $2.95
News
-
System76 Teams up with HP to Create the Dev One Laptop
HP and System76 have come together to develop a new laptop, powered by Pop!_OS and aimed toward developers.
-
Titan Linux is a New KDE Linux Based on Debian Stable
Titan Linux is a new Debian-based Linux distribution that features the KDE Plasma desktop with a focus on usability and performance.
-
Danielle Foré Has an Update for elementary OS 7
Now that Ubuntu 22.04 has been released, the team behind elementary OS is preparing for the upcoming 7.0 release.
-
Linux New Media Launches Open Source JobHub
New job website focuses on connecting technical and non-technical professionals with organizations in open source.
-
Ubuntu Cinnamon 22.04 Now Available
Ubuntu Cinnamon 22.04 has been released with all the additions from upstream as well as other features and improvements.
-
Pop!_OS 22.04 Has Officially Been Released
From the makers of some of the finest Linux-powered desktop and laptop computers on the market comes the latest version of their Ubuntu-based distribution, Pop!_OS 22.04.
-
Star Labs Unveils a New Small Format Linux PC
The Byte Mk I is an AMD-powered mini Linux PC with Coreboot support and plenty of power.
-
MX Linux Verison 21.1 “Wildflower” Now Available
The latest release of the systemd-less MX Linux is now ready for public consumption.
-
Microsoft Expands Their Windows Subsystem for Linux Offerings With AlmaLinux
Anyone who works with Windows Subsystem for Linux (WSL) will now find a new addition to the available distributions, one that’s become the front-runner replacement for CentOS.
-
Debian 11.3 Released wIth Numerous Bug and Security Fixes
The latest point release for Debian Bullseye is now available with some very important updates.