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