From e107695a2da2fbd282d7dbb1edf77d51756ef87f Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Fri, 27 Jun 2008 11:16:15 +1200 Subject: [PATCH] Initial import of my tools. --- mpc-addall | 8 +++++++ mpc-rotate | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 mpc-addall create mode 100755 mpc-rotate diff --git a/mpc-addall b/mpc-addall new file mode 100755 index 0000000..c7a7e09 --- /dev/null +++ b/mpc-addall @@ -0,0 +1,8 @@ +#! /bin/sh +# +# Add all the songs that mpd knows about, except for regexes in exclude_songs. + +mpc clear +mpc listall | grep -v -f /home/sounds/etc/exclude_songs | mpc add +mpc shuffle +mpc play diff --git a/mpc-rotate b/mpc-rotate new file mode 100755 index 0000000..7da0556 --- /dev/null +++ b/mpc-rotate @@ -0,0 +1,65 @@ +#!/bin/bash + +#state=/var/run/mpc-playlist +state=/tmp/mpc-playlist + +if [ -f $state ] +then + . $state +fi + +play_general() { + mpc-addall > /dev/null +} + +save_state() { + echo "State: $1" + echo "PLAYLIST=$1" > $state +} + +#PLAYLIST=children + +mpc --no-status stop + +if [ "x$PLAYLIST" == "x" ] +then + play_general + save_state 'general' +else + LISTS=($(find /home/sounds/playlists -type f -print0 | xargs --null -L 1 -I{} basename {} .m3u | grep -v Christmas | sort)) + + index=0 + element_count=${#LISTS[@]} + + while [ "$index" -lt "$element_count" ] + do + echo "Looking at $index, ${LISTS[$index]}" + + if [ "$PLAYLIST" == "${LISTS[$index]}" ] + then + echo -n found current + let "next = ($index + 1) % $element_count" + echo "next : ${LISTS[$next]} ($next)" + next_list=${LISTS[$next]} + + play /home/sounds/prompts/$next_list.wav + + if [ $next_list == 'general' ] + then + play_general + else + mpc --no-status clear + mpc --no-status load $next_list + mpc --no-status shuffle + mpc --no-status play + fi + + save_state $next_list; + + exit + fi + let "index=$index + 1" + + done +fi + -- 2.30.2