Mercurial > rlm
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-all4 (:gen-class5 :name rlm.playAll6 :main true)7 (:use [clojure.contrib8 [shell-out :only [sh]]9 [accumulators :only [combine]]10 [command-line :only [with-command-line]]11 [duck-streams :only [file-str]]]12 [rlm13 [shell-write :only [sw]]14 [shell-inspect :only [command-line?]]]))17 (def allowed-types18 [#".*\.mp3$"19 #".*\.m4a$"20 #".*\.wav$"])22 (def music23 ["/home/r/Desktop/first-archive/sounds"])25 (defn music-files []26 (shuffle27 (doall (filter28 (fn [b] (some (fn [a] (re-matches a (.getPath b))) allowed-types))29 (apply combine30 (map #(apply vector %)31 (map file-seq32 (map file-str music))))))))34 (defn enqueue35 [#^java.io.File file]36 (sh "totem" "--enqueue" (.getPath file)))38 (defn play-all-music39 "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 args47 "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*))