-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcoverart.sh
47 lines (35 loc) · 1.11 KB
/
coverart.sh
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
#!/bin/bash
#coverart.sh
DEFAULT_COVER="./icons/ic_album_white_48dp.png"
# for 'mpd' users
# the mpd.conf line should be in the following format
# music_directory "/var/mpd/Music"
MUSICDIR=`cat /etc/mpd.conf | grep -v "#" | grep music_directory`
MUSICDIR=${MUSICDIR:16}
MUSICDIR=${MUSICDIR%/$}
MUSICDIR=${MUSICDIR:1:${#MUSICDIR}-2} # only required is the path is surrounded by " "
MFILE=`mpc current -f %file%`
MFILE=${MFILE%/*}
MFILE=${MFILE%/$}
FULLDIR="$MUSICDIR/$MFILE"
## for 'moc' users under Debian, not sure if other distros use the 'mocp' name for the program:
#MFILE=`mocp --format "%file"`
#[ -n "$MFILE" ] && FULLDIR=`dirname "$MFILE"`
[ -n "$FULLDIR" ] && COVERS=`ls "$FULLDIR" | grep "\.jpg\|\.png\|\.gif"`
if [ -z "$COVERS" ]; then
COVERS="$DEFAULT_COVER"
else
TRYCOVERS=`echo "$COVERS" | grep -i "cover\|front\|folder\|albumart" | head -n 1`
if [ -z "$TRYCOVERS" ]; then
TRYCOVERS=`echo "$COVERS" | head -n 1`
if [ -z "$TRYCOVERS" ]; then
TRYCOVERS="$DEFAULT_COVER"
else
TRYCOVERS="$FULLDIR/$TRYCOVERS"
fi
else
TRYCOVERS="$FULLDIR/$TRYCOVERS"
fi
COVERS="$TRYCOVERS"
fi
echo -n "$COVERS"