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
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters
Find SysAdmin Jobs
News
-
LibreOffice 7.5 has Arrived and is Loaded with New Features and Improvements
The favorite office suite of the Linux community has a new release that includes some visual refreshing and new features across all modules.
-
The Next Major Release of Elementary OS Has Arrived
It's been over a year since the developers of elementary OS released version 6.1 (Jólnir) but they've finally made their latest release (Horus) available with a renewed focus on the user.
-
KDE Plasma 5.27 Beta Is Ready for Testing
The latest beta iteration of the KDE Plasma desktop is now available and includes some important additions and fixes.
-
Netrunner OS 23 Is Now Available
The latest version of this Linux distribution is now based on Debian Bullseye and is ready for installation and finally hits the KDE 5.20 branch of the desktop.
-
New Linux Distribution Built for Gamers
With a Gnome desktop that offers different layouts and a custom kernel, PikaOS is a great option for gamers of all types.
-
System76 Beefs Up Popular Pangolin Laptop
The darling of open-source-powered laptops and desktops will soon drop a new AMD Ryzen 7-powered version of their popular Pangolin laptop.
-
Nobara Project Is a Modified Version of Fedora with User-Friendly Fixes
If you're looking for a version of Fedora that includes third-party and proprietary packages, look no further than the Nobara Project.
-
Gnome 44 Now Has a Release Date
Gnome 44 will be officially released on March 22, 2023.
-
Nitrux 2.6 Available with Kernel 6.1 and a Major Change
The developers of Nitrux have officially released version 2.6 of their Linux distribution with plenty of new features to excite users.
-
Vanilla OS Initial Release Is Now Available
A stock GNOME experience with on-demand immutability finally sees its first production release.