-
Notifications
You must be signed in to change notification settings - Fork 2
/
albumart
33 lines (28 loc) · 884 Bytes
/
albumart
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
#!/bin/bash
MUSIC_DIR=~/music/
COVER=/tmp/cover.jpg
function reset_background
{
printf "\e]20;;100x100+1000+1000\a"
}
{
album="$(mpc --format %album% current -p 6601)"
file="$(mpc --format %file% current -p 6601)"
album_dir="${file%/*}"
[[ -z "$album_dir" ]] && exit 1
album_dir="$MUSIC_DIR/$album_dir"
covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
src="$(echo -n "$covers" | head -n1)"
rm -f "$COVER"
if [[ -n "$src" ]] ; then
convert "$src" -resize 700x "$COVER"
if [[ -f "$COVER" ]] ; then
#scale down the cover to 30% of the original
printf "\e]20;${COVER};70x70+87+00:op=keep-aspect\a"
else
reset_background
fi
else
reset_background
fi
} &