All patches and comments are welcome. Please squash your changes to logical
commits before using git-format-patch and git-send-email to
patches@git.madduck.net.
If you'd read over the Git project's submission guidelines and adhered to them,
I'd be especially grateful.
3 # A simple cover fetcher script for current playing song on mpd.
5 # Author : Wolfgang Mueller
7 # Adapted for Lain internal use.
8 # https://github.com/copycat-killer/lain
10 # You can use, edit and redistribute this script in any way you like.
12 # Dependencies: imagemagick.
14 # Usage: mpdcover <music_directory> <song_file> <cover_resize> <default_art>
16 # Configuration-------------------------------------------------------
24 # Regex expression used for image search
25 IMG_REG="(Front|front|Cover|cover|Art|art|Folder|folder)\.(jpg|jpeg|png|gif)$"
27 # Path of temporary resized cover
28 TEMP_PATH="/tmp/mpdcover.png"
33 if [ $COVER_RESIZE == "x" ]; then
34 COVER_RESIZE="100x100"
37 # The default cover to use (optional)
40 # Thumbnail background (transparent)
41 COVER_BACKGROUND="none"
43 #--------------------------------------------------------------------
45 # check if anything is playing at all
46 [[ -z $file ]] && exit 1
49 art="$MUSIC_DIR/${file%/*}"
51 # find every file that matches IMG_REG set the first matching file to be the
53 cover="$(find "$art/" -maxdepth 1 -type f | egrep -i -m1 "$IMG_REG")"
55 # when no cover is found, use DEFAULT_ART as cover
56 cover="${cover:=$DEFAULT_ART}"
58 # check if art is available
59 if [[ -n $cover ]]; then
60 if [[ -n $COVER_RESIZE ]]; then
61 convert "$cover" -thumbnail $COVER_RESIZE -gravity "center" -background "$COVER_BACKGROUND" -extent $COVER_RESIZE "$TEMP_PATH"