3

I was wondering if there is a program that would choose a wallpaper from a directory and set it as my desktop background automatically every time I log in.

I've already tried Desktop Drapes, the Compiz wallpaper plug in (from the extras package) and Wallpapoz, but those don't seem to work. Is there a script I can make that will do it for me?

I'm running 11.04 official release. Any help would be much appreciated.

Bruno Pereira
  • 73,643
Leron
  • 1,660

2 Answers2

2

After some thought, I just stripped down my RandomQuotedWallpaper script and came up with a more simple RandomWallpaper script. Just set it for startup with your session and don't forget to add your wallpaper folder in the config session.

Here is also the complete script for convenience:

#!/bin/bash

# This is a script which sets a random wallpaper.
# Some ideas are coming from the xplanet-script located at: http://rbrusu.com/xplanet-desktop-wallpape.html

# Public Domain or CC0

function setGnome() {
    gconftool -t str -s /desktop/gnome/background/picture_filename $1
}

function setMate() {
    mateconftool-2 -t str -s /desktop/mate/background/picture_filename $1
}

# Directory of the wallpapers
wallpaperdir=~/Wallpapers
sleep=3m

if [ ! -d "$wallpaperdir" ]; then
    echo "$wallpaperdir does not exist!"
fi

newWallpaper=$(ls "$wallpaperdir" | sort --random-sort | head -n 1)


setGnome "$wallpaperdir/$newWallpaper"

# Wait for some time and then start over.
sleep $sleep
exec $0
Bobby
  • 784
0

I can see that there is already an answer accepted here but it was posted while I was making this script, so I would like to put it here too. ;-)

You can make this script run putting a link to it at your "Startup Applications".

Make a file and paste this into it:

#!/bin/bash
# 
# by desgua
#
# to pick a random picture and make it the desktop wallpaper
#
###################################################################

pic=$(ls ~/Pictures/*/*.jpg | while read x; do echo "`expr $RANDOM % 100000`:$x"; done | sort -n| sed 's/[0-9]*://' | head -1)

gconftool-2 --type str --set /desktop/gnome/background/picture_filename $pic

exit 0

Remember to make it executable.

References: 1, 2.

desgua
  • 32,917