Monday, April 23, 2007

Re: [BLUG] random wallpaper in Ubuntu

FYI: You don't need to be root to do that.

There is no reason to use 'sudo' for that command. The script can be
installed in ~/bin. Of course, your cron daemon may not recognize the ~
in pathnames, so you should probably use $HOME explicitly there.

The script can reference $HOME/Pictures or the $1 argument, removing
the requirement for hard-coded paths. (All cron programs work properly
with arguments to the commands that they run.)

Additionally, even if you wanted the script available for everyone on
your system, it is bad practice to put it in /bin. It would be better
to put in in /usr/local/bin. (Or perhaps in /usr/local/stow with the
proper symlinks.)

Truthfully, though, such a mechanism would be wasteful to allow as-is
in a multi-user system. A better approach would be something that can
be started from the session manager so that it only runs for the active
user -- and only when users are logged in.

Cheers,
Steven Black

Quoting Ben Shewmaker <benshewmaker@yahoo.com>:

> I wish Gnome had an option to easily set it to randomly select a new
> wallpaper every x minutes, but, alas, it doesn't. I'm sure this is
> nothing new to most of you, but it took me a little while to figure
> this one out, so I thought I'd share in case anybody didn't know.
> And if you know of a better way to do this, please let me know!
>
> 1. sudo gedit
>
> 2. copy this, but replace /home/ben/wallpaper/ with the directory
> where you have your wallpapers:
>
> #!/bin/bash
>
> # Set your folder with the pics
> picsfolder="/home/ben/wallpaper/"
>
> # Go to your folder with the pics
> cd "$picsfolder"
>
> # Get the name of a random file
> randomfile=`ls *.jpg *.png |sed -n $((RANDOM%$(ls *.jpg *.png |wc -l)+1))p`
>
> # start of gconftool command and set the desktop
> gconftool-2 -t str --set /desktop/gnome/background/picture_filename
> "$picsfolder$randomfile"
>
> 3. save as changewallpaper.sh in /bin
>
> 4. 'sudo chmod +x /bin/changewallpaper.sh'
>
> 5. 'crontab -e'
>
> 6. add these lines:
> */15 * * * * changewallpaper.sh
> @reboot changewallpaper.sh
>
> 7. save and exit
>
> And that should be it. At least it was for me. That changes the
> wallpaper every boot and every 15 minutes. I also added a custom
> application launcher to my panel with the command
> '/bin/changewallpaper.sh' and I can click that button to randomly
> select a new wallpaper if I don't like the current one. Oh, and I
> like http://interfacelift.com/ for good wallapapers. Also, I didn't
> write that little script, I stole it from this thread:
> http://ubuntuforums.org/showthread.php?t=329164&highlight=random+wallpaper
>
> ben
>
>
>
>
>
>
>
>
>
> ---------------------------------
> Ahhh...imagining that irresistible "new car" smell?
> Check outnew cars at Yahoo! Autos.

_______________________________________________
BLUG mailing list
BLUG@linuxfan.com
http://mailman.cs.indiana.edu/mailman/listinfo/blug

No comments: