FollieHiyuki-dotfiles/home/.config/ncmpcpp/album_art.sh

33 lines
991 B
Bash
Raw Normal View History

2021-04-15 11:14:02 -04:00
#!/bin/sh
2021-02-13 11:28:59 -05:00
MUSIC_DIR=$HOME/Music/
COVER=/tmp/cover.jpg
if command -v mako >/dev/null
then
notification=mako
else
notification=dunst
fi
2021-02-13 11:28:59 -05:00
{
file="$(mpc --format %file% current -p 6600)"
album_dir="${file%/*}"
2021-04-15 11:14:02 -04:00
if [ -z "$album_dir" ]; then exit 1; fi
2021-02-13 11:28:59 -05:00
album_dir="$MUSIC_DIR/$album_dir"
covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(Album\|album\|Cover\|cover\|Folder\|folder\|Artwork\|artwork\|Front\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
2021-04-15 11:14:02 -04:00
src="$(echo "$covers" 2>/dev/null | tr -d '\n' | head -n1)"
2021-02-13 11:28:59 -05:00
rm -f "$COVER"
# For Notifications
2021-04-15 11:14:02 -04:00
if [ -n "$src" ] ; then
2021-02-13 11:28:59 -05:00
# Resize the image's width to 64px
convert "$src" -resize 64x "$COVER"
2021-04-15 11:14:02 -04:00
if [ -f "$COVER" ] ; then
notify-send -u low -i ${COVER} " Now Playing" "$(mpc --format '%title% \n%artist% - %album%' current)"
2021-02-13 11:28:59 -05:00
fi
else
notify-send -u low -i $HOME/.config/${notification}/headphones.png " Now Playing" "$(mpc --format '%title% \n%artist% - %album%' current)"
2021-02-13 11:28:59 -05:00
fi
} &