---
title: "Random Images From Xkcd as Wallpaper"
description: "Afterhowto use real-time earth wallpaper i tired to make some random xkcd images as my wallpaper. The below is a simple."
url: "https://h3manth.com/scribe/random-images-xkcd-wallpaper/"
canonical_url: "https://h3manth.com/scribe/random-images-xkcd-wallpaper/"
markdown_url: "https://h3manth.com/scribe/blog/random-images-xkcd-wallpaper.md"
publishDate: "2010-06-20T00:00:00.000Z"
author: "Hemanth HM"
category: "linux"
tags: ["bash","web","linux"]
word_count: 164
reading_time_minutes: 1
x_markdown_tokens: 400
content_signal: "ai-train=yes, search=yes, ai-input=yes"
---

# Random Images From Xkcd as Wallpaper

> Afterhowto use real-time earth wallpaper i tired to make some random xkcd images as my wallpaper. The below is a simple.

**After[howto use real-time earth wallpaper](http://www.h3manth.com/content/how-use-real-time-earth-wallpaper-script-linux) i tired to make some random xkcd images as my wallpaper.** _The below is a simple script which one can use to get random images from xkcd as desktop wallpapers at a time interval of 3600 seconds_ ` Steps: 1. mkdir -p ~/.xkcd 2. Place the code in this dir, call it xkcds.bash. 3. Setup a cron job or put the code in rc, as : 0 * * * * ~/.xkcd/xkcds.bash [or] cp ~/xkcd/xkcds.bash /etc/init.d/ && update-rc.d xkcds.bash defaults `
    
    
    #!/bin/bash
    
    while [ 1 ]; do
    
    # Remove old images if any!
    rm -rf *.png
    
    #Get the random image
    wget $(curl -sL "http://dynamic.xkcd.com/random/comic/" \
        | grep "http://imgs.xkcd.com/comics/"\
        | awk -Fsrc=\" '{print $2}'\
        |awk -F\" '{print $1}') -O xkcd-$(date +'%S').png
    
    #Set the image based on the desktop session
    
    [[ $DESKTOP_SESSION == "gnome"]] && gconftool-2 --type string --set \
    /desktop/gnome/background/picture_filename ~/.xkcd/xkcd*.png
    
    [[ $DESKTOP_SESSION == "kde" ]] &&  dcop kdesktop KBackgroundIface \
    setWallpaper xkcd*.png 1
    
    #Have a nap
    sleep 3600
    
    done
