Auto-Update Sun Map Wallpaper in KDE4

Yesterday, LifeHacker posted an article on setting up an auto-rotate wallpaper in Gnome. Now, KDE4 comes with this functionality out of the box - just point the desktop configuration to an image folder, and it will rotate the images in user-specified intervals (with a minimum of one hour). However, one comment by joelena caught my interest. Joelena mentioned having found a way to display a “sun map” as a wallpaper using a scheduled wget command.

Apparently, Gnome will automatically detect changes in the wallpaper image file, and update the desktop accordingly. No joy with KDE4 - apparently the devs assume we’ll never change the image :) . Fortunately, there’s a way to “trick” the KDE4 wallpaper rotator into updating the wallpaper with the latest sun map image.

First, create a folder to contain the sun map images, I created /usr/share/wallpapers/worldmap . Next, setup a cron job to automatically pull the updated image. Run “sudo crontab -e” in a terminal. This will start you editing root’s cron file. Paste the following as it’s own line in the cron file (Shift+Insert usually acts as paste for CLI editors):

10 * * * * wget http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg -O- | convert - -scale 1440×900 /usr/share/wallpapers/worldmap/worldmap.png && cp /usr/share/wallpapers/worldmap/worldmap.png /usr/share/wallpapers/worldmap/worldmap1.png
 

Be sure that it’s all on one line, and be sure to edit the -scale option for the convert command to match your own screen resolution, and the directory paths to match your directory. Save and exit. This command will pull the sun map image from the server that maintains it, and run it through the convert command to rescale it and convert it to a PNG image. Then, it will copy the output file to a file in the same directory with a different name. The cron options (the “10 * * * *”) specify that the command will be run ten minutes after every hour (apparently the map image is updated shortly after every hour).

Alternatively, you can copy and paste the following into a plain text file, add the proper permissions to make the file executable (chmod +x file), and use whatever scheduling software you like to run the script shortly after every hour:

#!/bin/bash

dir="/usr/share/wallpapers/worldmap"
file="worldmap"
file2="worldmap1"
format="png"
scale="1440×900"

wget http://www.opentopia.com/images/cams/world_sunlight_map_rectangular.jpg -O- | convert - -scale ${scale} ${dir}/${file}.${format}
cp ${dir}/${file}.${format} ${dir}/${file2}.${format}
 

This script does the same thing, but in a more easily customizable form.

Once you have the script setup, run it once to get the initial files, and point KDE4’s wallpaper slideshow to the directory containing the two files. It will loop through the two files (both of which are updated every hour), constantly updating your wallpaper with the changes.

Yahoo! Buzz Reddit Digg Design Float    StumbleUpon    Delicious Magnolia Furl    Subscribe via RSS Subscribe via EMail What is RSS?

2 Comments:

  1. Just wanted to mention that you will need imagemagick for the ‘resizing’ to work.

    Thanks for the great little hack! ^_^

  2. I have found that a shortcut to this same thing which I am now using for xplanet is to create a soft-link to the output image in the same directory. This tricks KDE4 into rotating the image and removes the need to script the \"rotation\".

No Pingbacks

Leave a Comment

You need to enable javascript in order to use Simple CAPTCHA.