I have scheduled a job in crontab to change the desktop background randomly, every minute in Lubuntu, using the following script:
#!/bin/bash export DISPLAY=:0 PHOTOS_PATH=~/Pictures/wallpapers/ number_of_photos=$(ls $PHOTOS_PATH | wc -l) # generates a random number in range 1 through $number_of_photos random=$( shuf -i 1-$number_of_photos -n 1 ) # returns the name of the file at line number $random of `ls` output photo_file=$(ls $PHOTOS_PATH | head --lines=$random | tail --lines=1) pcmanfm --set-wallpaper=$PHOTOS_PATH/$photo_file exit 0
But every minute, the following error message appears on the screen:
The problem is with the line of the script that issues command
pcmanfm, since (according to my experiments) this message appears exactly at the execution of that command. I've also run this script from inside tty1, and it changed my desktop background successfully, with no error. How can I overcome this problem with crontab?