Less CPU, replacement image, better log
This commit is contained in:
parent
677fcfa9ba
commit
8fcaab7cc7
41
kunst
41
kunst
|
@ -4,41 +4,58 @@ COVER=/tmp/kunst.jpg
|
|||
MUSIC_DIR=~/Music/
|
||||
CURRENT=$(mpc current -f %file%)
|
||||
|
||||
read -d '' MUSIC_NOTE << EOF
|
||||
iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJESURBVGhD7Zg/axRRFMVXAtpYphEVREKClnHfJI0MmReSfAC3tRejhaBgo70fwN7aD2BvEU0gfztbu5AqMxNjoVnvG87KZXy7z5m5dxLI/OCw8Pade+7M3n3Dbq+jo6OjY8RwMJhKk+hhlph3eRJ9w/LF5jCOr1PTj6jpD7mNjkjDkbDl4vFjpX87teZJlkSfSD9501zYfv5QJ1fyZHGexuJtZs12ZqMzX8NlwX4+nK3NXMutWaOm39Nd/u5rMCSUao80fjBNwY+p8Y+krNxQVaGsLsfWzFLYS2r4M30Rf5WbaCJE6OILlhIidPEFSwkRuviCpYQIXXzB1WX26bR6ky4v3OPriNCFB1YRHa079Pr6eKk/h1IFfA+WdOGBk+QeXtT0Ft3pV6e2fxf2f+AeLOnCA8tC0xv09H1xGi/cgWUi3I8lXXigEzX8u3gmWPP8JI5uYdt/w2thSRceSM0/zVfnb+CtWvB6WNJFOlC6XhDpQOl6QaQDpesFkQ6UrhdEOlC6XpA6gcPB/avumKXnxCadXHkha766tTr1GlE18CRZvEmN7nHfOMGiS5XA4mdmYg64Z5Jg06VKYHlEQoKtOVIz6zx8f0iwNUNyZt2F+3zjBFt9pGe22gWYFLb6lEckJNjGUmWEssR8ga0+0jNL9Z75fD7Rp7UOW32kZxb/1u37vFyUu+sODtjqozGzxaFADfprFM3vuD3Y3gytmf17LJPHXbgTNb5BWhe58yNan1lpWp9ZDVqdWS1am9mOjo7LRq/3B1ESKyYUVquzAAAAAElFTkSuQmCC
|
||||
EOF
|
||||
|
||||
update_cover() {
|
||||
# extract the album art from the mp3 file and dont show the messsy
|
||||
# output of ffmpeg
|
||||
ffmpeg -i "$MUSIC_DIR$(mpc current -f %file%)" $COVER -y &> /dev/null
|
||||
|
||||
echo "Extracted album art"
|
||||
STATUS=$?
|
||||
|
||||
if [ $STATUS -eq 0 ];then
|
||||
echo "kunst: extracted album art"
|
||||
ARTLESS=false
|
||||
else
|
||||
echo "error: file does not have an album art"
|
||||
ARTLESS=true
|
||||
return
|
||||
fi
|
||||
|
||||
# resize the image to 250x250
|
||||
convert $COVER -resize 250x250 $COVER
|
||||
|
||||
echo "Resized album art to 250x250"
|
||||
echo "kunst: resized album art to 250x250"
|
||||
}
|
||||
|
||||
|
||||
|
||||
main() {
|
||||
update_cover
|
||||
echo "Swapped art to $(mpc current)"
|
||||
|
||||
#mpv --keep-open=yes --cursor-autohide=always --no-osd-bar --no-osc --title="cover" --force-window=immediate --geometry 250x250 $COVER &
|
||||
if [ $ARTLESS == true ];then
|
||||
COVER=/tmp/kunst.png
|
||||
echo $MUSIC_NOTE | base64 --decode > $COVER
|
||||
fi
|
||||
|
||||
echo "kunst: swapped album art to $(mpc current)"
|
||||
|
||||
sxiv -g 250x250 -b $COVER &
|
||||
|
||||
|
||||
while true; do
|
||||
NEW=$(mpc current -f %file%)
|
||||
if [ "$NEW" != "$CURRENT" ];then
|
||||
CURRENT=$NEW
|
||||
echo "Song changed. Swapping album art"
|
||||
mpc idle &> /dev/null
|
||||
echo "kunst: received event from mpd"
|
||||
|
||||
update_cover
|
||||
update_cover
|
||||
|
||||
# mpv --keep-open=yes --no-osd-bar --no-osc --title="cover" --force-window --geometry 250x250 $COVER &
|
||||
echo "Swapped art to $(mpc current)"
|
||||
if [ $ARTLESS == true ];then
|
||||
COVER=/tmp/kunst.png
|
||||
echo $MUSIC_NOTE | base64 --decode > $COVER
|
||||
fi
|
||||
|
||||
echo "kunst: swapped album art to $(mpc current)"
|
||||
done
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue