summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tom Willemse2014-04-13 16:26:51 +0200
committerGravatar Tom Willemse2014-04-13 16:26:51 +0200
commit8dbc2e972ef6b6eedee4d621cb5b55a1e3ddfc57 (patch)
tree4c495e5149bd9f43a377c15c77deff83b7051913
downloadplayall-8dbc2e972ef6b6eedee4d621cb5b55a1e3ddfc57.tar.gz
playall-8dbc2e972ef6b6eedee4d621cb5b55a1e3ddfc57.zip
Initial commitHEADmaster
-rwxr-xr-xplayall35
1 files changed, 35 insertions, 0 deletions
diff --git a/playall b/playall
new file mode 100755
index 0000000..836f082
--- /dev/null
+++ b/playall
@@ -0,0 +1,35 @@
+#!/usr/local/bin/scsh -s
+!#
+;;; playall --- Play everything in my music collection in random order
+
+;;; Commentary:
+
+;; Uses `systemctl' to determine if MPD is active, and if so uses
+;; `mpc' to clear the current playlist, add all the songs in MPD's
+;; database to the current playlist, shuffle it and then start
+;; playing.
+
+;;; Code:
+
+(define mpd-state
+ (let ((raw-state
+ (run/string (systemctl --no-pager -p ActiveState show mpd))))
+ (substring raw-state
+ (+ (string-index raw-state #\=) 1) ; After the `='
+ (- (string-length raw-state) 1)))) ; Before the `\n'
+
+(if (string<> mpd-state "active")
+ (begin
+ (format
+ #t "MPD is not active, state is reported as \"~a\".~%" mpd-state)
+ (exit 1)))
+
+(run (mpc clear))
+(fork/pipe (lambda () (run (mpc listall))))
+(&& (mpc add)
+ (mpc shuffle)
+ (mpc play))
+
+;; Local Variables:
+;; mode: scheme
+;; End: