Like I somewhat promised, here's the wallpaper script with support for showing the lyrics of the currently playing song in mpd.

Dependencies

Usage

The usage is pretty simple, you have a directory filled with wallpapers again and one filled with the lyrics of the songs you like to listen to. Ncmpcpp saves them as a .txt file with the artist and title as the filename. (Band of Awesome - Cool Song.txt) Show the script the two directories in the settings, configure the rest and you're set. The script changes background and lyrics when the song changes, or background and fortune every 5 minutes.

The script

#!/bin/sh
#Configurables:
DIR=/home/USERNAME/Pictures/Wallpapers
TEMPDIR=/tmp
LYRICSDIR=/home/USERNAME/.lyrics
FORTUNEFILE=songs-poems
TIMETOSLEEP="5m"

RANGE=$(ls -1 "$DIR"/*.jpg "$DIR"/*.png | wc -l)
FLOOR=1

overlaylyrics()
{
   convert -size 1024x768 xc:none -gravity center
   -stroke black -strokewidth 2 -annotate 0 "@$LYRICSDIR/$(mpc current).txt"
   -background none -shadow 100x3+0+0 +repage
   -stroke none -fill white -annotate 0 "@$LYRICSDIR/$(mpc current).txt"
   $1 +swap -gravity center -geometry +0-3
   -composite $TEMPDIR/background.png
}

overlayfortune()
{
   fortune -s $FORTUNEFILE | expand > $TEMPDIR/quote.txt
   convert -size 1024x768 xc:none -gravity center
   -stroke black -strokewidth 2 -annotate 0 "@$TEMPDIR/quote.txt"
   -background none -shadow 100x3+0+0 +repage
   -stroke none -fill white -annotate 0 "@$TEMPDIR/quote.txt"
   $1 +swap -gravity center -geometry +0-3
   -composite $TEMPDIR/background.png
}

while [ 1 -eq 1 ]; do
   number=$RANDOM
   while [ "$number" -le $FLOOR ]; do
      number=$RANDOM
   done
   let "number%=$RANGE" # Scales $number down within $RANGE.
   COUNTER=1
   for X in "$DIR"/*.jpg "$DIR"/*.png
   do
      if [ $number -eq $COUNTER ]; then
         if [ -f "$LYRICSDIR/$(mpc current).txt" ]
         then
            overlaylyrics $X
            feh --bg-scale $TEMPDIR/background.png
            mpc idle
         else
            overlayfortune $X
            feh --bg-scale $TEMPDIR/background.png
            sleep $TIMETOSLEEP
         fi
      fi
      COUNTER=$(($COUNTER+1))
   done
   COUNTER=1
done

Fun hacks

You can play with the imagemagick convert command to give it interesting colours or something. I like this basic setup.


Comments