From 8702a04c3ffbd7bbad48bd669c11bc6cff39d5ee Mon Sep 17 00:00:00 2001 From: whut Date: Mon, 29 Mar 2021 22:46:20 -0500 Subject: [PATCH] inishul cuhmit --- .stations.example | 3 +++ tooner.sh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 .stations.example create mode 100755 tooner.sh diff --git a/.stations.example b/.stations.example new file mode 100644 index 0000000..0209948 --- /dev/null +++ b/.stations.example @@ -0,0 +1,3 @@ +Lainchan Cyberia|https://lainon.life/radio/cyberia.ogg +Lainchan Cafe|https://lainon.life/radio/cafe.ogg +Lainchan Everything|https://lainon.life/radio/everything.ogg diff --git a/tooner.sh b/tooner.sh new file mode 100755 index 0000000..7120519 --- /dev/null +++ b/tooner.sh @@ -0,0 +1,40 @@ +#!/bin/bash +! pgrep mpd && mpd +lastFile=/tmp/radioLast.$USER + +if [ $# -eq 0 ]; then + stationFile=~/.stations +else + stationFile=$1 +fi + +stations=`cat $stationFile` + +if [ -f "$lastFile" ]; then + last="$(cat $lastFile)" +else + touch $lastFile + chmod 660 $lastFile +fi + +names=() +urls=() +IFS=$'\n' +for item in $stations; do + if [ "$(echo $item | head -c 1)" != "#" ]; then + IFS='|' read -r name url <<< "$item" + names+=("$name") + urls+=("$url") + fi +done + +[ "${#names[@]}" -lt 10 ] && l=${#names[@]} || l=10 + +choice=`echo "${names[*]}" | rofi -i -dmenu -format i -l $l -width -30 -location 7 -theme android_notification -p "Radio" -no-custom -select $last` + +if [ ! -z "$choice" ]; then + mpc clear + mpc add ${urls[choice]} + mpc play + echo ${names[choice]} > $lastFile +fi