art.sh 974 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #!/bin/bash
  2. #put this file to ~/.ncmpcpp/
  3. MUSIC_DIR=~/Music/ #path to your music dir
  4. COVER=~/tmp/cover.jpg
  5. function reset_background
  6. {
  7. printf "\e]20;;100x100+1000+1000\a"
  8. }
  9. {
  10. album="$(mpc --format %album% current)"
  11. file="$(mpc --format %file% current)"
  12. album_dir="${file%/*}"
  13. [[ -z "$album_dir" ]] && exit 1
  14. album_dir="$MUSIC_DIR/$album_dir"
  15. covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
  16. src="$(echo -n "$covers" | head -n1)"
  17. rm -f "$COVER"
  18. if [[ -n "$src" ]] ; then
  19. #resize the image's width to 300px
  20. convert "$src" -resize 300x "$COVER"
  21. if [[ -f "$COVER" ]] ; then
  22. #scale down the cover to 30% of the original
  23. printf "\e]20;${COVER};35x35+0+00:op=keep-aspect\a"
  24. else
  25. reset_background
  26. fi
  27. else
  28. reset_background
  29. fi
  30. } &