Radio station picker for mpd using rofi
Vous ne pouvez pas sélectionner plus de 25 sujets
Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
|
- #!/bin/bash
- ! pgrep mpd > /dev/null && mpd
- lastFile=/tmp/radioLast.$USER
- nowPlaying=`mpc current -f "[%artist% - ]%title%"`
- nowPlaying=`echo $nowPlaying | sed 's/&/\&/g; s/</\</g; s/>/\>/g; s/"/\"/g; s/'"'"'/\'/g'`
- width=$((${#nowPlaying} > 30 ? ${#nowPlaying} : 30))
-
- 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 -mesg "<small>$nowPlaying</small>" -l $l -width -$width -location 7 -p "Radio" -no-custom -select $last -theme-str "#window { width: 50ch; }"`
-
- if [ ! -z "$choice" ]; then
- mpc clear > /dev/null
- mpc add ${urls[choice]} > /dev/null
- mpc play > /dev/null
- echo ${names[choice]} > $lastFile
- fi
|