I wrote a bash script that changes the wallpaper (for GNOME3).
#!/bin/bash # Wallpaper\'s directory. dir=\"${HOME}/images/wallpapers/\" # Random wallpaper.
add export DISPLAY=:0 && export XAUTHORITY=/home/username/.Xauthority , where username is your ubuntu username. It should fix the X11 authorisation error.