I am trying to set up crontab to run a script that will pick a random image from a folder and set it as my wallpaper in the morning, and another script that will do the same thing at night.
Goal is to have a random day and night wallpaper.
Got everything to work for a while by following the instructions from this post.
With this code:
#!/bin/bash
DIR="/path/to/wallpapers/"
PIC=$(ls $DIR/* | shuf -n1)
PID=$(pgrep gnome-session);
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-);
gsettings set org.gnome.desktop.background picture-uri "file://$PIC"
But my wallpaper just stopped updating after a day or so. I just tried setting cron to run this script every minute in an attempt to troubleshoot it (since that had worked in my tests before), but it just won't update my wallpaper anymore...
Does anyone know what could be the issue? Or know a better way/script to do it?
This is the full error message:
grep: /proc/1069: Is a directory
grep: 1501/environ: No such file or directory
(process:11303): dconf-CRITICAL **: 23:22:01.548: unable to create file '/home/user/.cache/dconf/user': Permission denied. dconf will not work properly.
(process:11303): dconf-CRITICAL **: 23:22:01.548: unable to create file '/home/user/.cache/dconf/user': Permission denied. dconf will not work properly.
(process:11303): dconf-CRITICAL **: 23:22:01.549: unable to create file '/home/user/.cache/dconf/user': Permission denied. dconf will not work properly.
(process:11303): dconf-WARNING **: 23:22:01.549: failed to commit changes to dconf: The given address is empty
Thanks in advance
-- Running Ubuntu 18.04
2>/tmp/cron.log
to your cronjob (or>/tmp/cron.log 2>&1
if you want to log both stderr and stdout) – steeldriver Aug 01 '20 at 02:09pgrep gnome-session
is returning more than a single PID – steeldriver Aug 01 '20 at 02:35-n
topgrep
has made it work again. Unsure if it will suddenly stop like before though, will give it a try Thanks for your help. @pa4080 I appreciate the posts, I did read them, and don't doubt the answer to my problem is there. But I lack knowledge on the topic (still fairly new to Linux), so a lot of the words just didn't mean much to me yet :/ Gonna see if the -n, has done it, otherwise I will look further into them, thanks. – dazzmos Aug 01 '20 at 16:45/path/to/script.sh: line 6: warning: command substitution: ignored null byte in input
(process:5866): dconf-CRITICAL **: 14:00:01.807: unable to create file '/home/user/.cache/dconf/user': Permission denied. dconf will not work properly.
– dazzmos Aug 01 '20 at 17:11