Mercurial > rlm
diff src/rlm/play_all.clj @ 0:78a630e650d2
initial import
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 18 Oct 2011 00:57:08 -0700 |
parents | |
children |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/rlm/play_all.clj Tue Oct 18 00:57:08 2011 -0700 1.3 @@ -0,0 +1,55 @@ 1.4 +":";exec java -cp $HOME/roBin/src:$HOME/roBin/lib/* clojure.main $0 $*; 1.5 + 1.6 +(ns rlm.play-all 1.7 + (:gen-class 1.8 + :name rlm.playAll 1.9 + :main true) 1.10 + (:use [clojure.contrib 1.11 + [shell-out :only [sh]] 1.12 + [accumulators :only [combine]] 1.13 + [command-line :only [with-command-line]] 1.14 + [duck-streams :only [file-str]]] 1.15 + [rlm 1.16 + [shell-write :only [sw]] 1.17 + [shell-inspect :only [command-line?]]])) 1.18 + 1.19 + 1.20 +(def allowed-types 1.21 + [#".*\.mp3$" 1.22 + #".*\.m4a$" 1.23 + #".*\.wav$"]) 1.24 + 1.25 +(def music 1.26 + ["/home/r/Desktop/first-archive/sounds"]) 1.27 + 1.28 +(defn music-files [] 1.29 + (shuffle 1.30 + (doall (filter 1.31 + (fn [b] (some (fn [a] (re-matches a (.getPath b))) allowed-types)) 1.32 + (apply combine 1.33 + (map #(apply vector %) 1.34 + (map file-seq 1.35 + (map file-str music)))))))) 1.36 + 1.37 +(defn enqueue 1.38 + [#^java.io.File file] 1.39 + (sh "totem" "--enqueue" (.getPath file))) 1.40 + 1.41 +(defn play-all-music 1.42 + "runs commands which enque music to totem from a separate thread. 1.43 + just run this command and don't worry about it anymore." 1.44 + [] 1.45 + (.start (Thread. (partial sh "totem"))) 1.46 + (.start (Thread. (fn [] (dorun (map enqueue (music-files))))))) 1.47 + 1.48 +(defn -main [& args] 1.49 + (with-command-line args 1.50 + "Play every Music File ever :)" 1.51 + [] 1.52 + (println "playing all music from" music) 1.53 + (play-all-music) 1.54 + )) 1.55 + 1.56 + 1.57 +(if (command-line?) 1.58 + (apply -main *command-line-args*))