=== Bash code Ref. [[http://ubuntuforums.org/showthread.php?p=7210276#post7210276|DBUS_SESSION]] {{{ #! /bin/bash ###################################################################### # Description : Randomly change desktop background from a folder # which contains lots of desktop pictures # Version : 2.0.0 ###################################################################### #--------setting-------------- pic_dir=/path-to-pictures #--------end----------------- # Get the pid of nautilus nautilus_pid=$(pgrep -u $LOGNAME -n nautilus) # If nautilus isn't running, just exit silently if [ -z "$nautilus_pid" ]; then exit 0 fi # Grab the DBUS_SESSION_BUS_ADDRESS variable from nautilus's environment eval $(tr '' ' ' < /proc/$nautilus_pid/environ | grep '^DBUS_SESSION_BUS_ADDRESS=') # Check that we actually found it if [ -z "$DBUS_SESSION_BUS_ADDRESS" ]; then echo "Failed to find bus address" >&2 exit 1 fi # export it so that child processes will inherit it export DBUS_SESSION_BUS_ADDRESS pic=$(ls $pic_dir/*.jpg | shuf -n1) gconftool --type string --set /desktop/gnome/background/picture_filename $pic exit 0; }}} Save the above code to file and change its permission and add it to a cron command! You are done! === More about command {{{ ls -l | grep ^- | wc -l #Get total number of regular files ls -l | grep ^d | wc -l #Get total number of subdirectories ls -l | grep ^l | wc -l #Get total number of symbolic links ls | shuf -n1 #Randomly get one file }}}