elhackerlibre

albumart.sh

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