Skip to content

Instantly share code, notes, and snippets.

@punchagan punchagan/qotd.sh
Created Nov 29, 2011

Embed
What would you like to do?
Pick a random image from a directory and annotate the text message onto it.
#!/bin/bash
# Usage ./qotd.sh "This is sample text"
# Depends
# - Gnome2/3
# - ImageMagick
# TODO
# - Add intelligent font color selection
# - Intelligent placement of text.
PICDIR="/home/punchagan/pics/downloaded"
SIZE="+200k"
LENGTH=50
photo=$(find $PICDIR -iregex ".*\(png\|jpg\|jpeg\|gif\)" -type f -size $SIZE|shuf|head -1)
tmp_photo=/tmp/background$RANDOM
quote=$(echo $1|sed "s/--/\n\n-/g"|fold -s -w $LENGTH)
convert "$photo" -fill white -font Helvetica -gravity NorthEast -pointsize 25 -annotate +100+100 "$quote" "$tmp_photo"
uri="file://"$tmp_photo
# For Gnome-3
gsettings set org.gnome.desktop.background picture-uri "$uri"
# For Gnome-2
# gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$uri"
echo $photo set as background!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.