DebianThis forum is for the discussion of Debian Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I give up. This is beyond my abilities. For the life of me I can't figure out why this doesn't work with Debian but it does with other distros. But Debian is the best distro for this machine, so I'm just going to use Variety to change the wallpaper in Mate. I'm done. It will remain unsolved...
Excellent idea. Crontab apparently called testwm which called materia, but I got no response on the desktop. If I call materia manually, it does change the wallpaper. But it didn't do that through crontab. Here's testwm.log:
Thu Jul 4 11:21:01 EDT 2019
DISPLAY is :0
x is 9667 ? 00:00:00 mate-session
y is
z is
Called /home/ewl/bin/materia
Done!
Ok, so now you know that /home/ewl/bin/materia is being run, it's time to debug that script.
the output from that script when run under from the modified /home/ewl/bin/testwm
should end up in /home/ewl/testwm.log. So how about /home/ewl/bin/materia
Code:
#!/bin/sh
# Script to randomly set Background from files in a directory
echo "This is $0"
# Directory Containing Pictures
DIR="/home/ewl/Pictures/Wallpapers"
echo "DIR is $DIR"
# Command to Select a random jpg file from directory
# Delete the *.jpg to select any file but it may return a folder
PIC=$(ls $DIR/* | shuf -n1)
echo PIC is $PIC
# Command to set Background Image
which gesttings
gsettings set org.mate.background picture-filename $PIC
If there is no output from the above echos etc. in the log file, then try explicitly redirecting to a log file in materia.
the output from that script when run under from the modified /home/ewl/bin/testwm
should end up in /home/ewl/testwm.log. So how about /home/ewl/bin/materia
If there is no output from the above echos etc. in the log file, then try explicitly redirecting to a log file in materia.
Evo2.
Thu Jul 4 22:28:01 EDT 2019
DISPLAY is :0
x is 1040 ? 00:00:00 mate-session
y is
z is
This is /home/ewl/bin/materia
DIR is /home/ewl/Pictures/Wallpapers
PIC is /home/ewl/Pictures/Wallpapers/city-wallpaper-12.jpg
/usr/bin/gsettings
Called /home/ewl/bin/materia
Done!
ok, next check the gsettings.... reading the gsettings man page...
Update the last few lines of your materia script to be
Code:
gsettings get org.mate.background picture-filename
echo "gettings return value was $?"
gsettings set org.mate.background picture-filename $PIC
echo "gettings return value was $?"
gsettings get org.mate.background picture-filename
echo "gettings return value was $?"
The if $? is not 0 then gsettings is reporting some sort of error.
Hmm, there seems to be an interesting "monitor" option. You could try running
ok, next check the gsettings.... reading the gsettings man page...
Update the last few lines of your materia script to be
The if $? is not 0 then gsettings is reporting some sort of error.
Hmm, there seems to be an interesting "monitor" option. You could try running
while the cron job executes.
Just keep digging.
Evo2.
Here's the testwm.log:
Fri Jul 5 11:24:01 EDT 2019
DISPLAY is :0
x is 1103 ? 00:00:00 mate-session
y is
z is
This is /home/ewl/bin/materia
DIR is /home/ewl/Pictures/Wallpapers
PIC is /home/ewl/Pictures/Wallpapers/moon-in-sky-3.jpg.jpg
'/home/ewl/Pictures/Wallpapers/variety-copied-wallpaper-92d9453b74067d549681e481924911ab.jpg'
gsettings return value was 0
gsettings return value was 0
'/home/ewl/Pictures/Wallpapers/moon-in-sky-3.jpg.jpg'
gsettings return value was 0
Called /home/ewl/bin/materia
Done!
the gsettings monitor command didn't produce any results.
SOLVED IT!! I figured out that the problem was somehow with the gsettings command, so I googled "crontab gsettings" and got a link to https://askubuntu.com/questions/7428...ings-from-cron . Using what I got from this page I added
to the beginning or the materia script, and it now changes the wallpaper. It all had to do with environment variables, or whatever. I'm too old to actually learn what all this means, but the script works in cron now. That's all that matters.
I want to thank all the people who helped me with this.
Whenever I've run into this kind of problem, i.e. a script runs OK for the user but fails when called as a cron job, it invariably turned out to be due to the cron environment and the user environment having PATH differences. It's usually fixed by rewriting the script to have full absolute paths to all called locations and executables.
It turns out you were right, but I didn't know how to go about fixing the problem.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.