ruwee

Untitled

Jan 22nd, 2018
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. MUSIC_DIR=/home/ruwee/music
  4.  
  5. COVER=/tmp/cover.jpg
  6.  
  7. function reset_background
  8. {
  9. printf "\e]20;;100x100+1000+1000\a"
  10. }
  11.  
  12. {
  13. album="$(mpc --format %album% current)"
  14. file="$(mpc --format %file% current)"
  15. album_dir="${file%/*}"
  16. [[ -z "$album_dir" ]] && exit 1
  17. album_dir="$MUSIC_DIR/$album_dir"
  18.  
  19. covers="$(find "$album_dir" -type d -exec find {} -maxdepth 1 -type f -iregex ".*/.*\(${album}\|cover\|folder\|artwork\|front\).*[.]\(jpe?g\|png\|gif\|bmp\)" \; )"
  20. src="$(echo -n "$covers" | head -n1)"
  21. rm -f "$COVER"
  22. if [[ -n "$src" ]] ; then
  23. #resize the image's width to 300px
  24. convert "$src" -resize 300x "$COVER"
  25. if [[ -f "$COVER" ]] ; then
  26. #scale down the cover to 30% of the original
  27. #place it 1% away from left and 50% away from top.
  28. printf "\e]20;${COVER};75x75+3+20:op=keep-aspect\a"
  29. else
  30. reset_background
  31. fi
  32. else
  33. reset_background
  34. fi
  35. } &
Advertisement
Add Comment
Please, Sign In to add comment