mpd: default art added

This commit is contained in:
luke bonham 2013-09-18 00:27:46 +02:00
parent c2d27aec72
commit f31c5cc856
2 changed files with 19 additions and 12 deletions

View File

@ -11,7 +11,7 @@
# #
# Dependencies: imagemagick. # Dependencies: imagemagick.
# #
# Usage: mpdcover <music_directory> <song_file> <default_art> # Usage: mpdcover <music_directory> <song_file> <cover_resize> <default_art>
# Configuration------------------------------------------------------- # Configuration-------------------------------------------------------
@ -22,7 +22,7 @@ MUSIC_DIR=$1
file=$2 file=$2
# Regex expression used for image search # Regex expression used for image search
IMG_REG="(front|cover|art|Folder|folder)\.(jpg|jpeg|png|gif)$" IMG_REG="(Front|front|Cover|cover|Art|art|Folder|folder)\.(jpg|jpeg|png|gif)$"
# Path of temporary resized cover # Path of temporary resized cover
TEMP_PATH="/tmp/mpdcover.png" TEMP_PATH="/tmp/mpdcover.png"
@ -34,6 +34,9 @@ if [ $COVER_RESIZE == "x" ]; then
COVER_RESIZE="100x100" COVER_RESIZE="100x100"
fi fi
# The default cover to use (optional)
DEFAULT_ART=$4
# Thumbnail background (transparent) # Thumbnail background (transparent)
COVER_BACKGROUND="none" COVER_BACKGROUND="none"
@ -49,6 +52,9 @@ art="$MUSIC_DIR/${file%/*}"
# cover. # cover.
cover="$(find "$art/" -maxdepth 1 -type f | egrep -i -m1 "$IMG_REG")" cover="$(find "$art/" -maxdepth 1 -type f | egrep -i -m1 "$IMG_REG")"
# when no cover is found, use DEFAULT_ART as cover
cover="${cover:=$DEFAULT_ART}"
# check if art is available # check if art is available
if [[ -n $cover ]]; then if [[ -n $cover ]]; then
if [[ -n $COVER_RESIZE ]]; then if [[ -n $COVER_RESIZE ]]; then

View File

@ -33,6 +33,7 @@ local function worker(args)
local port = args.port or "6600" local port = args.port or "6600"
local music_dir = args.music_dir or os.getenv("HOME") .. "/Music" local music_dir = args.music_dir or os.getenv("HOME") .. "/Music"
local cover_size = args.cover_size or 100 local cover_size = args.cover_size or 100
local default_art = args.default_art or ""
local settings = args.settings or function() end local settings = args.settings or function() end
local mpdcover = helpers.scripts_dir .. "mpdcover" local mpdcover = helpers.scripts_dir .. "mpdcover"
@ -85,8 +86,8 @@ local function worker(args)
then then
helpers.set_map("current mpd track", mpd_now.title) helpers.set_map("current mpd track", mpd_now.title)
os.execute(string.format("%s %q %q %d", mpdcover, music_dir, os.execute(string.format("%s %q %q %d %q", mpdcover, music_dir,
mpd_now.file, cover_size)) mpd_now.file, cover_size, default_art))
mpd.id = naughty.notify({ mpd.id = naughty.notify({
preset = mpd_notification_preset, preset = mpd_notification_preset,