view 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 source
1 ":";exec java -cp $HOME/roBin/src:$HOME/roBin/lib/* clojure.main $0 $*;
3 (ns rlm.play-all
4 (:gen-class
5 :name rlm.playAll
6 :main true)
7 (:use [clojure.contrib
8 [shell-out :only [sh]]
9 [accumulators :only [combine]]
10 [command-line :only [with-command-line]]
11 [duck-streams :only [file-str]]]
12 [rlm
13 [shell-write :only [sw]]
14 [shell-inspect :only [command-line?]]]))
17 (def allowed-types
18 [#".*\.mp3$"
19 #".*\.m4a$"
20 #".*\.wav$"])
22 (def music
23 ["/home/r/Desktop/first-archive/sounds"])
25 (defn music-files []
26 (shuffle
27 (doall (filter
28 (fn [b] (some (fn [a] (re-matches a (.getPath b))) allowed-types))
29 (apply combine
30 (map #(apply vector %)
31 (map file-seq
32 (map file-str music))))))))
34 (defn enqueue
35 [#^java.io.File file]
36 (sh "totem" "--enqueue" (.getPath file)))
38 (defn play-all-music
39 "runs commands which enque music to totem from a separate thread.
40 just run this command and don't worry about it anymore."
41 []
42 (.start (Thread. (partial sh "totem")))
43 (.start (Thread. (fn [] (dorun (map enqueue (music-files)))))))
45 (defn -main [& args]
46 (with-command-line args
47 "Play every Music File ever :)"
48 []
49 (println "playing all music from" music)
50 (play-all-music)
51 ))
54 (if (command-line?)
55 (apply -main *command-line-args*))