123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/usr/bin/env bash
- MUSIC_DIR=~/Music/ # Your music directory
- COVER=/tmp/cover.jpg
- function reset_background
- {
- printf "\e]20;;100x100+1000+1000\a"
- }
- {
- album="$(mpc --format %album% current -p 6600)"
- file="$(mpc --format %file% current -p 6600)"
- 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"
-
- # For Album Art
- if [[ -n "$src" ]] ; then
- # Resize the image's width to 300px
- convert "$src" -resize 300x "$COVER"
- if [[ -f "$COVER" ]] ; then
- # Scale down the cover to 62% of the original
- printf "\e]20;${COVER};65x65+87+00:op=keep-aspect\a"
- else
- reset_background
- fi
- else
- reset_background
- fi
-
- # For Notifications
- if [[ -n "$src" ]] ; then
- # Resize the image's width to 64px
- convert "$src" -resize 64x "$COVER"
- if [[ -f "$COVER" ]] ; then
- notify-send -u normal -i ${COVER} " Now Playing" "`mpc current`"
- fi
- fi
- } &
|