Results 1 to 10 of 63

Thread: HOWTO: Finally! How to easily change your desktop to a random file at specified times

Threaded View

  1. #1
    Join Date
    Jul 2006

    HOWTO: Finally! How to easily change your desktop to a random file at specified times

    Ok, on these forums I found very silly ways to change your desktop picture randomly at intervals. Some involved installing programs, daemons, or using python(!) to achieve this simple task. Here is the solution, using plain old methods.

    First, a shell script is used. This will do most of the work - basically the windows equivalent is a batch file, except this is advanced. This is the code, pretty intuitive:

    # Set your folder with the pics
    # Go to your folder with the pics
    cd $picsfolder
    # Create an array of the files
    # Get the size of the array
    # Select a random number between this range
    # Get the name of this file
    # a bit overly complicated. basically it takes the Nth string from files ${files[$N]}, and then removes the first two letters which is the "./" at the beginning 
    randomfile=`echo ${files[$N]} | cut --characters="1 2" --complement`
    # start of gconftool command and set the desktop
    gconftool-2 -t str --set /desktop/gnome/background/picture_filename "$picsfolder$randomfile"
    Note that the last command is what does the work - it calls a program to set this "registry key" thing to point to your new file. Now to actually make this code do stuff, we have to save it to a file. In a terminal do this:

    execute: gksu gedit
    paste the above code
    save to: /bin/
    exit the gedit
    execute: gksu chmod +x /bin/
    now we have a script to change the wallpaper. we have also made the file executable (+x). you can run it in your terminal by typing
    Now to make it run every so often, you use cron - a schecheduling program that most linux distributions has. In a terminal do this:

    execute: crontab -e
    add an extra line: */15 * * * *
    add an extra line: @reboot
    press: control+x
    press: y
    press: enter
    what that means is that every 15 minutes and every time the computer starts, it will run
    modify that 15 if you want.
    check for more cron info

    Here are some other suggestions, and some seem better

    Copied from
    If your wallpapers do not change, just add them to the gnome wallpaper manager. After it seems like the wallpapers change

    Quoted from pt123:
    I get the error:
    scripts/ 10: arith: syntax error: "RANDOM%921+1"
    pt123's solution:
    I found why it wont work when called in a terminal from another forum. if you're running ubuntu you may find /bin/sh is symlinked to dash and not bash. sometimes you find weird errors occurring because of that.
    So the solution was:
    rm /bin/sh
    ln -s /bin/bash /bin/sh
    Last edited by davidY; March 4th, 2007 at 06:43 AM.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts