I hacked together a small script which rotates my wallpaper and overlays a fortune quote. Why? I have no idea. Just thought I should share my scripts more often, so here it is.
Dependencies
- fortune
- imagemagick
- feh (you could easily do with something else here, replace line 35 in the script)
Usage
You just dump a bunch of .JPG or .PNG wallpapers you like in a folder and change the DIR variable in the script. Give it the path to the temporary directory that it should use and pick a fortune file. (you can see all files available by typing 'fortune -f' on the commandline) Then run the script and it will give you a new random wallpaper with a random fortune on it every 5 minutes. You can change the time between the different wallpapers by changing the TIMETOSLEEP variable.
The script
#!/bin/sh #Configurables: DIR=/home/USERNAME/Pictures/Wallpapers TEMPDIR=/tmp FORTUNEFILE=wisdom TIMETOSLEEP="5m" RANGE=$(ls -1 "$DIR"/*.jpg "$DIR"/*.png | wc | awk '// {print $1}') FLOOR=1 number=0 overlayfortune() { fortune -s $FORTUNEFILE | expand > $TEMPDIR/quote.txt width=$(identify -format %w "$1"); convert -background '#0006' -fill white -gravity east -size ${width}x80 caption:@$TEMPDIR/quote.txt "$1" +swap -gravity south -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 overlayfortune $X feh --bg-scale $TEMPDIR/background.png fi COUNTER=$(($COUNTER+1)) done COUNTER=1 sleep $TIMETOSLEEP done
Disclaimer
I don't think there's a lot that could go wrong here but don't blame me if you do screw up. It works fine here.
Comments