-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmpd-thumbnail
More file actions
executable file
·29 lines (25 loc) · 881 Bytes
/
mpd-thumbnail
File metadata and controls
executable file
·29 lines (25 loc) · 881 Bytes
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
#!/bin/bash
# Must have script for anyone using MPD; needs imv since it supports socket ctl
# shows local albumart for currently playing song
# Uses basically no CPU
music_dir=~/Music
[ -f /tmp/albumart ] && rm /tmp/albumart
imv -b "#222222" -s shrink & sleep "1.5" # Sleep necessary for imv to init
pid=$!
extract(){
[ -f /tmp/albumart ] && rm /tmp/albumart
song_path=$(mpc -f %file% | head -1)
song_name=$(cut -f 1 -d '.' <(echo "$song_path"))
if $(ffmpeg -loglevel 8 -i "$music_dir/$song_path" -f image2 "/tmp/albumart"); then true
elif [ -f "$music_dir/$song_name.jpg" ]; then
cp "$music_dir/$song_name.jpg" "/tmp/albumart"
elif [ -f "$music_dir/$song_name.png" ]; then
cp "$music_dir/$song_name.jpg" "/tmp/albumart"
fi
}
display(){
if [ -f /tmp/albumart ]; then
imv-msg $pid "open /tmp/albumart" || exit
fi
}
while true; do extract; display; mpc idle; done