Warning: Declaration of GTranslate::widget($args) should be compatible with WP_Widget::widget($args, $instance) in /var/www/ninjatool.dk/blog/wp-content/plugins/gtranslate/gtranslate.php on line 0
Randomly generated wallpaper on login | NinjaTool inc.

Randomly generated wallpaper on login

Posted by on February 18, 2011

I got the idea from my “new” s10 because I wanted to keep the desktop clean, simple but with a touch of personality. For this reason I thought it would be cool with a stylish wallpaper and a simple picture frame on it showing a new picture chosen at random from a defined photo folder. I first thought of making a widget (or downloading one) that could add this picture frame on top of the static wallpaper, but then I thought “Why not just generate the wallpaper on login?” So that’s the project now… I spent about 10 minutes at work searching the web and here’s what I found;

First i came across a 3 line script for selecting a random picture from a specified folder and inserting it as wallpaper on the Ubuntu desktop.

Secondly I needed something to generate the wallpaper. For this purpose ImageMagick seemed like a great tool given its obvious power and console nature.

So this is what I came up with. Simple, but does the trick :)

#!/bin/bash
# Script to select random image from a directory, polaroid style it and paste it on a full screen wallpaper image.
# Directory Containing Pictures
DIR="[your image dir]"
# Command to Select a random file from directory
PIC=$(ls $DIR/script_candidates/*.* | shuf -n1)
# Style the selected image as a polaroid picture
convert $PIC -bordercolor snow -background black +polaroid -thumbnail '300x300>' $DIR/overlay_temp.png
# Append on top of a full screen wallpaper image. (the 700x300 offset just fit my needs)
composite -geometry +700+200 $DIR/overlay_temp.png $DIR/wp_bg.jpg $DIR/wp_cmp.png
# Command to set Background Image
gconftool -t string -s /desktop/gnome/background/picture_filename $DIR/wp_cmp.png

I now have the script running upon login, and thereby have a newly generated, random wallpaper to look at every time I log in. One resulting wallpaper could (and indeed did) look like this:

133 Responses to Randomly generated wallpaper on login

  1. Mikael H. Møller

    This is really nice! Thank you for a brilliant idea, and the nice script.

    Hope to see you in Hal9k some day :)

    / Mikael

Leave a Reply


Fatal error: Uncaught Error: Call to undefined function fetch_rss() in /var/www/ninjatool.dk/blog/wp-content/plugins/wp-cron/wp-cron-dashboard.php:18 Stack trace: #0 /var/www/ninjatool.dk/blog/wp-includes/class-wp-hook.php(298): wp_cron_dashboard('') #1 /var/www/ninjatool.dk/blog/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters('', Array) #2 /var/www/ninjatool.dk/blog/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #3 /var/www/ninjatool.dk/blog/wp-content/plugins/wp-cron/wp-cron.php(62): do_action('wp_cron_hourly') #4 /var/www/ninjatool.dk/blog/wp-includes/class-wp-hook.php(298): wp_cron_hourly_exec('') #5 /var/www/ninjatool.dk/blog/wp-includes/class-wp-hook.php(323): WP_Hook->apply_filters(NULL, Array) #6 /var/www/ninjatool.dk/blog/wp-includes/plugin.php(453): WP_Hook->do_action(Array) #7 /var/www/ninjatool.dk/blog/wp-includes/load.php(677): do_action('shutdown') #8 [internal function]: shutdown_action_hook() #9 {main} thrown in /var/www/ninjatool.dk/blog/wp-content/plugins/wp-cron/wp-cron-dashboard.php on line 18