summaryrefslogtreecommitdiffstats
path: root/playall
blob: 836f0825682967b5ea6bf2f2bd70538c781fcf57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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: