Skip to content

Instantly share code, notes, and snippets.

@albertmatyi
Last active November 1, 2017 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save albertmatyi/6a2e33be0e7fa62f8bb32c297eeaef5d to your computer and use it in GitHub Desktop.
Save albertmatyi/6a2e33be0e7fa62f8bb32c297eeaef5d to your computer and use it in GitHub Desktop.
Select and listen to a radio station from Digitally Imported with mplayer & dmenu

twt

Usage

  1. Put this script in your path
  2. Install dmenu & mplayer
  3. Run via $> radio-di.sh
#!/bin/bash -xe
# stop previous mplayer
pkill mplayer || true
# use either the first script parameter or a default digitally imported playlist
PLAYLIST_URL=${1:-https://gist.githubusercontent.com/sim642/4f73e3e145fd1eac8c39/raw/43dbe82623404c0f549a7391b5a618f5fd89f4dc/DI.m3u}
# get the content and let the user
STATION_URLS=$(curl $PLAYLIST_URL | grep http)
# select one station using dmenu (simple UI based filtering)
STATION_URL=$(printf "$STATION_URLS" | dmenu)
# start player and display notification on track change
mplayer $STATION_URL \
| grep --line-buffered -Eo StreamTitle.* \
| grep --line-buffered -Eo "'[^']*'" \
| xargs -L 1 notify-send
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment