Created
November 29, 2011 18:13
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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