Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add music example script.

  • Loading branch information...
commit fd4c87b10c6e406505a09da21e1b82c2c5947584 1 parent 33d778b
@technomancy authored
Showing with 34 additions and 0 deletions.
  1. +34 −0 examples/music
View
34 examples/music
@@ -0,0 +1,34 @@
+#!/bin/bash
+
+# This example asks the user to pick a directory from ~/music or its
+# first argument and queues up its contents via mpd. http://musicpd.org
+
+music_home=${1:-"$HOME/music/"}
+
+# Cache directory list
+list_file="$music_home/.dirs"
+if [ ! -f "$list_file" ]; then
+ find "$music_home" -type d | cut -c $(echo $music_home | wc -c)- > "$list_file"
+fi
+
+# Ask the user
+chosen=`cat $list_file | erythrina`
+
+# Add it to mpd
+if [ "$chosen" != "" ]; then
+ mpc clear
+ mpc add "$chosen"
+ mpc play
+fi
+
+# You may find it helpful to bind these commands to keystrokes in
+# addition to this script:
+
+# notify-send "Now Playing" "`mpc | head -n 1`"
+
+##!/usr/bin/env ruby
+# current = `mpc`.split("\n").first
+# playlist = `mpc playlist`.split("\n")
+# current_index = playlist.index(current)
+# rest = playlist[(current_index + 1) .. (current_index + 5)].join("\n")
+# system "notify-send \"#{current}\" \"#{rest}\""
Please sign in to comment.
Something went wrong with that request. Please try again.