blob: b3f3c755c2c9220fe46960976b3beb8e8e564b46 (
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#!/bin/zsh
#set -x
export yprofile="qplay"
setopt shwordsplit
hist=0
OIFS="$IFS"
IFS='
'
lartist=$(mpc list artist)
lalbum=$(mpc list album)
xartist=$(for line in $lartist[(f)1,-1];do echo "artist $line";done| tr -d ';' | sort -k 2 -f -u)
xalbum=$(for line in $lalbum[(f)1,-1];do echo "album $line";done | tr -d ';' | sort -k 2 -f -u)
xhistory=$(tac ~/.mpd/.empd)
IFS="$OIFS"
term=`echo -e "$xartist\n$xalbum\n$xhistory" | ${(e)=YDMENU}`
[[ -z $term ]] && exit
#echo $term
if [[ $term == \;* ]];then
hist=1
fi
term=${term#;}
mtype="$term[(w)1]"
media="$term[(w)2,(w)-1]"
if [[ $term == *: ]];then
last=$(mpc playlist | wc -l)
if [[ $term == playlist* ]];then
hist=1
mpc load $mtype
else
mpc search $mtype "${media%:}" | mpc add
fi
mpc play $(($last + 1))
mpc pause
else
plist=$(mpc playlist | awk -F '-' '{ print substr($1,0,20) }' | sort -u -R | head -3 | tr '\n' ' ')
token=$RANDOM
echo ";playlist.$token $plist" >> ~/.mpd/.empd
mpc save playlist.$token
mpc clear
if [[ $term == playlist* ]];then
hist=1
mpc load $mtype
else
mpc search $mtype "$media" | mpc add
fi
fi
[[ $hist == 0 ]] && echo ";${term%:}" >> ~/.mpd/.empd
notify-send "Em-pee-dee" "$term added...."
#set +x
|