Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
    
Possible duplicate over at SU: Software for random wallpaper , But with custom text. You can find the always up-to-date script in one of my repositories at github. –  Bobby Apr 30 '11 at 21:33
    
Thank you, but that's time based. it is set to change the wall paper (by default) every three minutes. What I"m looking for is something that will choose the wallpaper at log in, and not need a daemon running or anything after that. Sorry if I was unclear. –  Leron Apr 30 '11 at 21:43

2 Answers 2

up vote 2 down vote accepted

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
share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.