It wasn't me. You can't prove anything.


2013-09-26

Gnome desktop background switcher

It turns out that the command below ‘gconftool-2’ does not function properly when executed from within a cron job. There is some environment issue because the script ran fine on the command line no matter what and indeed changed the value of the gnome conf database, but would not implement the change when run from a cron job.

I run this script from the gnome “Startup Applications” mechanism.

Put an integer number of seconds on  the command line. If left blank, it runs once (changes the background) and exists.

Original script found http://www.webupd8.org/2009/11/3-lines-script-to-automatically-change.html.
Bash script to swap out the background of the gnome desktop every x number of seconds.

#!/bin/bash
# found http://www.webupd8.org/2009/11/3-lines-script-to-automatically-change.html
# Script to randomly set Background from files in a directory

# Directory Containing Pictures
DIR="/space/wide"

# Command to set Background Image
changeMe() {
# Command to Select a random jpg file from directory
# Delete the *.jpg to select any file but it may return a folder
PIC=$(/bin/ls $DIR/*.jpg | /usr/bin/shuf -n1)
/usr/bin/gconftool-2 -t string -s /desktop/gnome/background/picture_filename $PIC
}

if [ ! -z $1 ]; then
seconds=$1
else
# Run onece and quit
changeMe
exit 0
fi

while true ; do
changeMe
sleep ${seconds}s
done

No comments: