#!/bin/bash # https://gist.github.com/vlevit/4588882 MUSIC_DIR="$HOME/audio/music" album="$(mpc --format %album% current)" file="$(mpc --format %file% current)" 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\)" \; )" cover="$(echo -n "$covers" | head -n1)" cp -f "$cover" /tmp/mpd.cover