notify 804 B

12345678910111213141516171819202122232425
  1. #!/usr/bin/env bash
  2. MUSIC_DIR=~/Music/ # Your music directory
  3. COVER=/tmp/cover.jpg
  4. {
  5. album="$(mpc --format %album% current -p 6600)"
  6. file="$(mpc --format %file% current -p 6600)"
  7. album_dir="${file%/*}"
  8. [[ -z "$album_dir" ]] && exit 1
  9. album_dir="$MUSIC_DIR/$album_dir"
  10. covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
  11. src="$(echo -n "$covers" | head -n1)"
  12. rm -f "$COVER"
  13. # For Notifications
  14. if [[ -n "$src" ]] ; then
  15. # Resize the image's width to 64px
  16. convert "$src" -resize 64x "$COVER"
  17. if [[ -f "$COVER" ]] ; then
  18. notify-send -u normal -i ${COVER} " Now Playing" "`mpc current`"
  19. fi
  20. fi
  21. } &