Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- settings=$HOME/Launchers/.tconk-settings-general
- # load variables from files
- . $settings
- IFS=$'\t' mpd_array=( $(MPD_HOST=::1 MPD_PORT=6600 \
- mpc --format "\t%artist%\t%album%\t%file%\t") );
- filename="mpd-cover.png";
- reference="$tmpfolder/mpd-${mpd_array[1]}"
- albumart="$tmpfolder/$filename"
- musicfolder="$basemusicfolder/${mpd_array[2]}"
- # if there's no album, set the reference to it to 'empty' so we don't end
- # up with an endless loop of disk writing $albumart
- if [ "$reference" = "$tmpfolder" ]; then
- reference="$tmpfolder/empty"
- fi
- # meat n' pooptatoes
- # see if we've already created art for this album
- if [ ! -f "$reference" ]; then
- # delete the old files
- rm -f "$tmpfolder"/mpd-* &> /dev/null
- # create the reference for the new album
- touch "$reference"
- # set a reference to any existing album art
- album=$(dirname "$musicfolder")
- coverFile=$(ls $album | egrep "jpeg|jpg|png|gif|bmp" | head -n 1)
- cover="$album/$coverFile"
- # see if album art exists at that reference and if so, use it
- if [ -f "$cover" ]; then
- convert "$cover" -resize "54>x" "$albumart";
- # otherwise, just use the placeholder
- else
- cp "$mpdFallbackIcon" "$albumart";
- fi
- fi
- # clean up if music is not playing
- exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement