Skip to content

Instantly share code, notes, and snippets.

@punchagan
Created November 29, 2011 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save punchagan/1405784 to your computer and use it in GitHub Desktop.
Save punchagan/1405784 to your computer and use it in GitHub Desktop.
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