]> git.etc.gen.nz Git - mpd-tools.git/commitdiff
Initial import of my tools.
authorAndrew Ruthven <andrew@etc.gen.nz>
Thu, 26 Jun 2008 23:16:15 +0000 (11:16 +1200)
committerAndrew Ruthven <andrew@cerberus.etc.gen.nz>
Thu, 26 Jun 2008 23:16:15 +0000 (11:16 +1200)
mpc-addall [new file with mode: 0755]
mpc-rotate [new file with mode: 0755]

diff --git a/mpc-addall b/mpc-addall
new file mode 100755 (executable)
index 0000000..c7a7e09
--- /dev/null
@@ -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 (executable)
index 0000000..7da0556
--- /dev/null
@@ -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
+