Advertisement
HiImTye

Launchers/.tconk-scripts-mpd.sh

Apr 8th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.24 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. settings=$HOME/Launchers/.tconk-settings-general
  4. # load variables from files
  5. . $settings
  6.  
  7. IFS=$'\t' mpd_array=( $(MPD_HOST=::1 MPD_PORT=6600 \
  8.           mpc --format "\t%artist%\t%album%\t%file%\t") );
  9. filename="mpd-cover.png";
  10. reference="$tmpfolder/mpd-${mpd_array[1]}"
  11. albumart="$tmpfolder/$filename"
  12. musicfolder="$basemusicfolder/${mpd_array[2]}"
  13. # if there's no album, set the reference to it to 'empty' so we don't end
  14.  # up with an endless loop of disk writing $albumart
  15. if [ "$reference" = "$tmpfolder" ]; then
  16.  reference="$tmpfolder/empty"
  17. fi
  18.  
  19. # meat n' pooptatoes
  20. # see if we've already created art for this album
  21. if [ ! -f "$reference" ]; then
  22.  # delete the old files
  23.  rm -f "$tmpfolder"/mpd-* &> /dev/null
  24.  # create the reference for the new album
  25.  touch "$reference"
  26.  # set a reference to any existing album art
  27.  album=$(dirname "$musicfolder")
  28.  coverFile=$(ls $album | egrep "jpeg|jpg|png|gif|bmp" | head -n 1)
  29.  cover="$album/$coverFile"
  30.  # see if album art exists at that reference and if so, use it
  31.  if [ -f "$cover" ]; then
  32.   convert "$cover" -resize "54>x" "$albumart";
  33.  # otherwise, just use the placeholder
  34.  else
  35.   cp "$mpdFallbackIcon" "$albumart";
  36.  fi
  37. fi
  38. # clean up if music is not playing
  39. exit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement