BASH SCRIPT to listening internet radio on Librem 5

I made and use this script on my PureOS laptop. Nowadays works almost without changes in Librem 5

I use three files to have a desktop shortcut (internetradio.desktop internetradio.png

open gedit or another text editor and write the following and save as internetradio.desktop file:

[Desktop Entry]
Name=Internet Radio

internetradio.desktop file should be in /home/purism/.local/share/applications/

Be sure to put the path were the bash script file will be stored ( i.e. Exec=/myhome/path/

the bash script file:

# Listen internet radio stations. By Antonio Paternina Alvarez. Press the number/letter of the station on menu. When running press Ctrl-C to stop, SPACEbar to see the menu. To exit menu press the [.] on your keyboard. 
#---------------define variables---------
tit="   Internet Radio" 
uno=" 1. ADVenir Bolivia"
dos=" 2. Altiplano AdVenir Bolivia"
tres=" 3. AMANECER VZLA *"
cuat=" 4. FAITH FM BELIZE"
cinc=" 5. GLOBAL FAMILY NETWORK - Guyana"
seis=" 6. La Perla" 
siet=" 7. LA VOZ Internacional VZLA"
ocho=" 8. Los Angeles del valle"
opcA=" A. NT Argentina"
opcB=" B. NT Bolivia"
opcC=" C. NT Brazil"
opcD=" D. NT Chile"
opcE=" E. NT Ecuador"
opcF=" F. NT Paraguay"
opcG=" G. NT Perú"
opcH=" H. NT Uruguay"
opcI=" I. RA España"
opcL=" L. Bogotá"
opcM=" M. Terceiro Anjo BR"
opcN=" N. WTPM 92.9FM"
oFin=" .  Exit"
#---------user defined function----------
show_menu() {
echo -ne "\033];$tit\007" # Set terminal window title
# echo "$tit"
# echo "$line"
 echo "$uno          $oFin"
 echo "$dos"
 echo "$tres"
 echo "$cuat"
 echo "$cinc"
 echo "$seis"
 echo "$siet"
 echo "$ocho"
 echo "$nuev"
 echo "$opcA"
 echo "$opcB"
 echo "$opcC"
 echo "$opcD"
 echo "$opcE"
 echo "$opcF"
 echo "$opcG"
 echo "$opcH"
 echo "$opcI"
 echo "$opcJ"
 echo "$opcK"
 echo "$opcL"
 echo "$opcM"
 echo "$opcN"
read_options() {
# read input from keyboard and take a action. # invoke the uno() when user select 1 from the menu option. #  ffmpeg -i $url -f mp3 -ar 44100 -ac 2 - ab 96000 - | ffplay -i -
    local choice
    while IFS= read -rn1 choice
	case $choice in
	    1) echo -ne "\033];$uno\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    2) echo -ne "\033];$dos\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    3) echo -ne "\033];$tres\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    4) echo -ne "\033];$cuat\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i -  ;;
	    5) echo -ne "\033];$cinc\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    6) echo -ne "\033];$seis\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    7) echo -ne "\033];$siet\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    8) echo -ne "\033];$ocho\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    9) echo -ne "\033];$nuev\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -i -nodisp -i -  ;;
	    a) echo -ne "\033];$opcA\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    b) echo -ne "\033];$opcB\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    c) echo -ne "\033];$opcC\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    d) echo -ne "\033];$opcD\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    e) echo -ne "\033];$opcE\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    f) echo -ne "\033];$opcF\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    g) echo -ne "\033];$opcG\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    h) echo -ne "\033];$opcH\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    i) echo -ne "\033];$opcI\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    j) echo -ne "\033];$opcJ\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    k) echo -ne "\033];$opcK\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    l) echo -ne "\033];$opcL\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    m) echo -ne "\033];$opcM\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    n) echo -ne "\033];$opcN\007"; ffmpeg -i "" -f mp3 -ar 44100 -ac 2 -ab 96000 - | ffplay -nodisp -i - ;;
	    .) exit 0 ;;
	    *) echo "Error..." && sleep 1 

# --------------------
#  Step 3. Trap Ctrl+C, Ctrl+Z and quit singles
# ------------------------------

# ------------------------------
#   Step 4. Main Logic - Infinite loop
# ------------------------------
while true


CHOOSE A image for your desktop shorcut and put it in /home/purism/.local/share/icons

Give execution attributes to with
chmod +x

That is all. The script will show a menu to choose the internet radio using numbers 1 to 9 and letters A to N. To exit just press the “.” dot

To exit/change to another station running Simple press Ctrl+C then press any key to see the menu again.

the icon i made:

Internetradio on the upper right on this screen shot:

the menu to select radio station:

Radio Station NT Paraguay playing

NT Paraguay radio station stop by pressing Ctrl-C

Playing option F. Radio Swiss Classical


I love your choice in music👍 and the script👍
Edit: How do you find the stream url for internet stations? I am trying to put in there but I can’t find the stream url

I inspect the webpage html looking for the streaming link; usually it ends with or .m3u8

It is not easy but it is possible mostly.

1 Like


But are you sure? I tried to listen to the guy speaking… I can’t. Anyway … if you like it, there you have it.

I found also.

Nowaday I am listening the man speaking using the link above in VLC. I put the link on Open Network Stream (Ctrl-N) from Media menu.

I am about to test it on ffmpeg | ffplay

1 Like

Thank you both so much, I tried that but I gave up to quickly🙄

Wasn’t Shortwave an option? :stuck_out_tongue:

1 Like

Maybe @epinez but I rather avoid flathub apps for generally use a lot of resources and storage. This is why I made a script with ffmpeg and ffplay which already installed on Librem 5 AFAIK.

1 Like

It occurs to me that all those streaming links will likely include trackers from those websites (as is also the case with apps like Shortwave). Have you considered any solution for preventing tracking? Just curious.

Solutions that come to mind are:

  1. Copy one of the common tracker-blocking scripts from github to the hosts file on the L5.

  2. Always use a VPN that has the option to incorporate such a list into your settings.

  3. Only use the radio links on your home network running the Pi-hole application to block trackers.

  4. Use a browser with javascript- and ad-blocking add-ons, instead of your script or instead of Shortwave-like apps.

  5. Do nothing to prevent tracking. :slight_smile:

I also wonder what info will the .m3u8 link receive from gnu ffmpeg | ffplay in this script.

It will say in the handshake we are using a Gnu Linux OS?

certainly I do not provide anything of that .

@ASwyD2 I added Kunyo as option O. thanks

Listening Kunyo station:

1 Like

How would that work? :thinking:

Thanks :+1::+1::+1::+1::+1::grinning:

I’m thinking that since the links come from a website, there is the potential to be tracked through the site. :man_shrugging:

I notice that copying one of @Tonyp’s streaming links to a browser’s url bar invokes a download dialog to open an .m3u8 in one’s default player application, so I’m not sure.

In Pi-hole on my network I can see the connection to, as one example,, but there seems to be no data tracker to block, fortunately.

1 Like

Testing some of my saved stations in Shortwave, mostly European music stations, I see connections being made to them in Pi-hole, but again, no apparent trackers. :+1:
(At least, not visible to the user.)

Nothing unusual, every DNS request goes through the Pi-hole in standard configuration :slight_smile:

But tracking is not really a thing here. Just look up the contents of the M3U file in a text editor. It does not work the same as in a browser; an audio player can only play/stream the audio. It does not make any other connections as in the usual tracking game. You would have to route your traffic through a VPN or Tor to hide your IP. User-agent is another thing.

1 Like

Challenge accepted says Surveillance Capitalism?

I’m not at all familiar with the protocol(s) here but the key question would seem to be: what information, if any, goes back in the other direction?

@amarok what can a tracker do when you play with
mpv stream-url

About the only thing I know for analytics is that the radio station typically tracks the amount of users connected, sometimes their geolocation (country), along with total concurrent bandwidth used amongst all of them, but that is the extent of it as far as I am aware.

I would rephrase that question as: “Are there any third-party trackers like Facebook, Google, TikTok, or Doubleclick embedded on the websites where those streams originate from?”

It’s not the idea of the first-party activity tracking by a website (or source) that I chose to visit that would concern me.

Admittedly I was just posing the question because I don’t know what goes on behind the scenes when you call up a stream over the internet. :wink:

1 Like

How do I find the streaming link? I’ve tried Ctr-U and I tried inspect (Q) and I can’t find the link that works.
( I’m trying to do this on again, They changed the stream link)
Sorry for not being able to do this myself.

1 Like