I’ve been listening to SomaFM on and off for almost 10 years. In this time I’ve used various methods to listen; from their web player to shell scripts that run mplayer with their station URLs.

I wanted to make a bite-sized project that involved making a GUI application for Linux, so I thought “why not a SomaFM player?”. For the GUI library, I picked PySimpleGUI. It seems to be a wrapper around Tcl/Tk.

=> https://github.com/PySimpleGUI/PySimpleGUI

Since I wanted to do it properly, nothing was hard-coded. I used the SomaFM API at https://somafm.com/channels.xml. This URL provides up-to-date information about all of their stations; station and DJ names, currently playing songs, listener counts and URLs that can be used to listen live.

The player supports multiple “backends” for playing audio. The following commands are tried in this order, before giving up.

  • mpv –no-video $URL
  • ffplay -nodisp $URL
  • clvc $URL
  • vlc $URL

Since ffplay comes with ffmpeg, I imagine this will cover a large range of distros that can use this application.

You can find the code at this URL.

=> https://github.com/gkbrk/scripts/blob/master/somafm.py