-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathshow_covers_w3mimage.sh
executable file
·66 lines (57 loc) · 1.63 KB
/
show_covers_w3mimage.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# requires mpc to get song info
########### Configuration
# TODO: Sane defaults and autodetect
MUSICDIR=~/music
TMPDIR=~/tmp
function get_album_art {
echo "### Finding cover for $ALBUM..."
coverart1="$SONGDIR"
#coverart1=$MUSICDIR/"$ALBUM"/"$ARTIST"
# trimming characters that jack it up...
coverart1=$(echo "$coverart1"| sed s/[:.]//g)
# getting lowercase and removing final slash
coverart="${coverart1,,}"
coverart="${coverart%/}"
if [ -f "$coverart/cover.jpg" ]; then
COVERART="$coverart/cover.jpg"
elif [ -f "$SONGDIR/folder.jpg" ]; then
COVERART="$coverart/folder.jpg"
else
curl https://unsplash.it/512/512/?random -o $TMPDIR/unsplash.jpg
convert $TMPDIR/unsplash.jpg -blur 0x3 $TMPDIR/unsplash_blur.jpg
COVERART="${$TMPDIR/unsplash_blur.jpg}"
fi
}
# uses xseticon, wmctrl, and transset to make its little terminal
# window all pretty. Feel free to delete these lines.
# snark=$(echo $WINDOWID)
# xseticon -id $snark ~/.icons/Faenza-Like/iKamasutra.png
# wmctrl -i -r "$snark" -T "Album Art Downloader"
# transset 0.7 -i "$snark"
(echo qman-startup; mpc idleloop) \
| while read event
do
if [ "$event" = "mixer" ]
then
continue
fi
if [ "$event" = "update" ]
then
continue
fi
ARTIST=$(mpc --format %artist% | head -1)
ALBUM=$(mpc --format %album% | head -1)
SONGFILE=$(mpc --format %file% | head -1)
SONGFILE=$MUSICDIR/"$SONGFILE"
SONGDIR=$(dirname "$SONGFILE")
if [ -f "$SONGFILE" ]; then
echo "Getting info for $ARTIST and $ALBUM"
get_album_art
echo "$COVERART"
w3mimg.sh "$COVERART"
else
echo "We're getting wrong information for some reason."
fi
done
fi