From 8dbc2e972ef6b6eedee4d621cb5b55a1e3ddfc57 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 13 Apr 2014 16:26:51 +0200 Subject: Initial commit --- playall | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 playall 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: -- cgit v1.2.3-54-g00ecf