title: Gsettings with cron
body: <p>I wrote a bash script that changes the wallpaper (for GNOME3).</p>
  
  <pre><code>#!/bin/bash
  
  # Wallpaper's directory.
  dir="${HOME}/images/wallpapers/"
  
  # Random wallpaper.
  wallpaper=`find "${dir}" -type f | shuf -n1`
  
  # Change wallpaper.
  # http://bit.ly/HYEU9H
  gsettings set org.gnome.desktop.background picture-options "spanned"
  gsettings set org.gnome.desktop.background picture-uri "file://${wallpaper}"
  </code></pre>
  
  <p>Script executed in a terminal emulator (eg gnome-terminal) works great. During the execution by cron, or ttyX terminal getting the error:</p>
  
  <pre><code>** (process:26717): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
  
  ** (process:26717): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
  
  ** (process:26721): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
  
  ** (process:26721): WARNING **: Command line `dbus-launch --autolaunch=d64a757758b286540cc0858400000603 --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
  </code></pre>