manr: fix
[copyleftie-scripts.git] / album
blob0da35fffd6d183462c28e5d1610c5f3145982b18
1 #!/bin/rc
2 # album - commands an existing mpv(1) to play an album from the filesystem.
3 #       this command expects ASCIInumerically sorted FLACs organized
4 #       in the structure $home/music/$artist/$album/$track
6 #       an mpv is expected to be already listening on the socket $tmp/mpv
8 #       BUGS
9 #               - mpv's playlist handling is insecure
10 #               - mpv is expected to have already loaded a playlist
11 #       TODO
12 #               - handle dmenu(1) allowing multiple selections
14 flag e +
15 flag x +
17 ls=(`{9 which ls} -p -Q)
19 fn play {
20         if (! test -d $1)
21                 exit 1
23         cd $1
24         for (f in *.flac)
25                 mpvc loadfile "$1/$f" append-play
28 fn get_album {
29         if (! test -d $1)
30                 exit 1
31         
32         album=`{ { echo '<< Back'; $ls $1 } |
33                 dmenu -p 'Album:' -i -l 10 |
34                 read}
35         if (! ~ $status '')
36                 exit 1
37         if (~ $album '<< Back')
38                 exec $0
40         play $1/$"album
43 artist=`{$ls $home/music |
44         dmenu -p 'Artist:' -i -l 10 |
45         read}
46 if (! ~ $status '')
47         exit 1
48 if not
49         get_album $home/music/$"artist