I wrote a script to change my desktop background. I want this script to run on anacron because I often turn my computer off at night. I've tested parts of the script, and I think the problem is with this line:
DISPLAY=:0 GSETTINGS_BACKEND=dconf gsettings set org.gnome.desktop.background picture-uri '"file://'$wallPath'"'
$wallPath is the wallpaper path)
It switches my wallpaper but it doesn't when anacron runs. I figured this was because anacron runs as root (I also check dconf for root and my user to check this). So I hacked up a way to run anacron as a specific user. But that didn't work.
Can anyone help me figure out a way to run gsettings as a user? I've tried su (username) -c 'sh run/this/script' to no avail. I've found some stuff about exporting some dbus env variables, but I'm having difficulty following it.