--- /dev/null
+#! /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
--- /dev/null
+#!/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
+