-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmpd.rc
executable file
·100 lines (86 loc) · 2.01 KB
/
cmpd.rc
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/usr/bin/env rc
#
# cmpd - client for mpd in rc
# need mpc
help_msg='usage: cmpd [-h]\ncommands:\n[n]\tplay n\nd/r\tremove song\np\ttoggle play/pause\nu\tupdate database\ns\tstop\nrn\ttoggle random\nrp\ttoggle repeat\nsn\ttoggle single\nc cn\ttoggle consume\ne q ESC\texit\n'
if (~ $1 h -h help -help --help) {
printf $help_msg
exit
}
fn list {
m=`{mpc current}
c=1 for (i in `` ($nl) {mpc playlist}) {
if (~ $i $"m) {
printf '| %02d %s\n' $c $i
} else {
printf ' %02d %s\n' $c $i
}
c=`{expr $c + 1}
}
}
list
while (true) {
echo -n '> '
a=`{awk '{print;exit}'}
switch ($a(1)) {
case l list
list
case [1-99]
mpc play $a(1) > /dev/null
echo playing `{mpc current}
case d delete
if (~ $a(2) ()) {
echo list a ARTIST
echo select a ARTIST NUMBER
continue
}
mpc del $a(2) > /dev/null
echo deleted $a(2)
case p toggle
mpc toggle > /dev/null
echo toggle
case u update
mpc update $a(2) > /dev/null
echo updated
case s stop
mpc stop > /dev/null
echo stop
case a add
if (~ $a(2) ()) {
echo list a ARTIST
echo select a ARTIST NUMBER
continue
}
n=`` ($nl) {mpc search artist $a(2)}
if (~ $n ()) { echo none; continue }
if (! ~ $a(3) () && ! test $a(3) -gt $#n) {
mpc add $n($a(3))
continue
}
m=1 for (o in `` ($nl) {printf '%s' $n$nl | sed 's/windows\///'}) {
printf '%02d %s\n' $m $o
m=`{expr $m + 1}
}
case z random
n=`{mpc random | tail -n 1 | awk '{print $6}'}
echo random $n
case r repeat
n=`{mpc repeat | tail -n 1 | awk '{print $4}'}
echo repeat $n
case y single
n=`{mpc single | tail -n 1 | awk '{print $8}'}
echo single $n
case c consume
n=`{mpc consume | tail -n 1 | awk '{print $10}'}
echo consume $n
case v vol volume
n=`{mpc volume $a(2) | tail -n 1 | awk '{print $2}' | sed 's/%//'}
echo volume $n
case h help
printf $help_msg
case e exit q quit
exit
case *
echo ???
}
}