Automatically view song lyrics as you listen

Tutorial – Lyrics-in-terminal

Article from Issue 246/2021

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.


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


$ 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


# set PATH so it includes user's
# private bin if it exists
if [ -d "$HOME/.local/bin" ]; then

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.

Figure 1: By default, Lyrics-in-terminal attaches itself to the Spotify client playback.

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.

Figure 2: The automatic lyrics search feature works with any audio player that can be controlled via D-Bus/MPRIS.

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
$ 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).

Figure 3: If necessary, you can determine the D-Bus name of a player with a D-Bus debugger such as D-Feet.

Buy this article as PDF

Express-Checkout as PDF
Price $2.95
(incl. VAT)

Buy Linux Magazine

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content

  • Sweet Dreams

    Bathtub singer Mike Schilli builds a Go tool that manages song lyrics from YAML files and helps him learn them by heart, line by line.

  • Rhythmbox

    Originally inspired by Apple’s iTunes, Rhythmbox organizes your music collection, and more.

  • Sayonara Player

    For a simple audio player, check out Sayonara Player, a great choice for enjoying all your favorite music, Internet radio, and podcasts.

  • ChordPro

    If you play a stringed instrument and want to record lyrics and chord changes, ChordPro gives you an elegant and convenient approach to getting it all on paper.

  • YouTube Players

    YouTube offers more than just funny kitten movies; you will also find more than 60 million music videos. With a native YouTube client for Linux, you can use this online jukebox as conveniently as your local music collection.

comments powered by Disqus
Subscribe to our Linux Newsletters
Find Linux and Open Source Jobs
Subscribe to our ADMIN Newsletters

Support Our Work

Linux Magazine content is made possible with support from readers like you. Please consider contributing when you’ve found an article to be beneficial.

Learn More