aboutsummaryrefslogtreecommitdiff
path: root/.config/awesome/lain/scripts/mpdcover
diff options
context:
space:
mode:
authorxero <x@xero.nu>2014-03-08 22:14:34 -0500
committerxero <x@xero.nu>2014-03-08 22:14:34 -0500
commitaedf4ef0ec9712789310b5b6d7d06af90f4f6261 (patch)
treeae25f438d4942195892dd9c311badcccf00dd4d8 /.config/awesome/lain/scripts/mpdcover
parent02dd2db6564b9e3fd1e1582724bbd188f5de7db6 (diff)
downloaddotfiles_ascii-aedf4ef0ec9712789310b5b6d7d06af90f4f6261.tar.xz
dotfiles_ascii-aedf4ef0ec9712789310b5b6d7d06af90f4f6261.zip
add awesome wm config files and v0.1.0 of ghost theme.
Diffstat (limited to '.config/awesome/lain/scripts/mpdcover')
-rwxr-xr-x.config/awesome/lain/scripts/mpdcover68
1 files changed, 68 insertions, 0 deletions
diff --git a/.config/awesome/lain/scripts/mpdcover b/.config/awesome/lain/scripts/mpdcover
new file mode 100755
index 0000000..f6cf0d6
--- /dev/null
+++ b/.config/awesome/lain/scripts/mpdcover
@@ -0,0 +1,68 @@
+#!/bin/bash
+#
+# A simple cover fetcher script for current playing song on mpd.
+#
+# Author : Wolfgang Mueller
+#
+# Adapted for Lain internal use.
+# https://github.com/copycat-killer/lain
+#
+# You can use, edit and redistribute this script in any way you like.
+#
+# Dependencies: imagemagick.
+#
+# Usage: mpdcover <music_directory> <song_file> <cover_resize> <default_art>
+
+# Configuration-------------------------------------------------------
+
+# Music directory
+MUSIC_DIR=$1
+
+# Song file
+file=$2
+
+# Regex expression used for image search
+IMG_REG="(Front|front|Cover|cover|Art|art|Folder|folder)\.(jpg|jpeg|png|gif)$"
+
+# Path of temporary resized cover
+TEMP_PATH="/tmp/mpdcover.png"
+
+# Resize cover
+COVER_RESIZE="$3x$3"
+
+if [ $COVER_RESIZE == "x" ]; then
+ COVER_RESIZE="100x100"
+fi
+
+# The default cover to use (optional)
+DEFAULT_ART=$4
+
+# Thumbnail background (transparent)
+COVER_BACKGROUND="none"
+
+#--------------------------------------------------------------------
+
+# check if anything is playing at all
+[[ -z $file ]] && exit 1
+
+# Art directory
+art="$MUSIC_DIR/${file%/*}"
+
+# find every file that matches IMG_REG set the first matching file to be the
+# cover.
+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
+if [[ -n $cover ]]; then
+ if [[ -n $COVER_RESIZE ]]; then
+ convert "$cover" -thumbnail $COVER_RESIZE -gravity "center" -background "$COVER_BACKGROUND" -extent $COVER_RESIZE "$TEMP_PATH"
+ cover="$TEMP_PATH"
+ fi
+else
+ rm $TEMP_PATH
+fi
+
+exit 0