#!/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: