This script uses pyradio, rofi, and the kitty terminal emulator.

  • The pyradio stations.csv file is read into an array
  • The array is then cleaned with an awk command and a sed command
  • The cleaned array is then piped into rofi
  • When a rofi choice is made, a grep for the selected item is done
  • Finally, the grepped line number is sent to pyradio using the -p command line flag

The format of the pyradio stations.csv file is shown below.

BBC Radio Ulster,http://a.files.bbci.co.uk/ms6/live/3441A116-B12E-4D2F-ACA8-C1984642FA4B/audio/simulcast/hls/uk/pc_hd_abr_v2/ak/bbc_radio_ulster.m3u8,,
LBC London,http://media-ice.musicradio.com:80/LBCLondon,,

#!/usr/bin/env bash

BROWSER=pyradio
MYFILE="$HOME/.config/pyradio/stations.csv"
stations=$(grep -n "" $MYFILE)

mylist=$(printf '%s\n' "${stations[@]}" | awk -F":" '{print $2}' | sed -E 's/^(.+),.+/\1/')
choice=$(printf '%s\n' "$mylist" | rofi -dmenu -i -l 25 -p "Station Picker ($BROWSER)") "$@" || exit

if [ "$choice" ]; then
  LINES=$(grep -n "$choice" $MYFILE)
  ME=$(echo $LINES | cut -d : -f 1)
  RUN=$(kitty --class my_term pyradio -p $ME)
fi