LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices


Reply
  Search this Thread
Old 07-04-2019, 10:34 AM   #16
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15

...

Last edited by ewlabonte; 07-04-2019 at 10:56 AM.
 
Old 07-04-2019, 11:27 AM   #17
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
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...
 
Old 07-04-2019, 07:56 PM   #18
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,
Quote:
Originally Posted by ewlabonte View Post
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.

Evo2.
 
Old 07-04-2019, 08:03 PM   #19
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by evo2 View Post
Hi,


Ok, so now you know that /home/ewl/bin/materia is being run, it's time to debug that script.

Evo2.
Here it is. But I don't see what there is to debug. It works fine when I run in a terminal.

#!/bin/sh
# Script to randomly set Background from files in a directory

# Directory Containing Pictures
DIR="/home/ewl/Pictures/Wallpapers"

# 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)

# Command to set Background Image
gsettings set org.mate.background picture-filename $PIC
 
Old 07-04-2019, 08:40 PM   #20
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

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.

Evo2.
 
Old 07-04-2019, 09:30 PM   #21
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by evo2 View Post
Hi,

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!
 
Old 07-04-2019, 09:31 PM   #22
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
Again materia was called but didn't change the wallpaper.
 
Old 07-04-2019, 09:47 PM   #23
evo2
LQ Guru
 
Registered: Jan 2009
Location: Japan
Distribution: Mostly Debian and CentOS
Posts: 6,724

Rep: Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705Reputation: 1705
Hi,

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
Code:
gsettings monitor org.mate.background picture-filename
while the cron job executes.


Just keep digging.

Evo2.
 
Old 07-05-2019, 10:27 AM   #24
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by evo2 View Post
Hi,

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.
 
Old 07-06-2019, 03:34 PM   #25
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
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

PID=$(pgrep mate-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)

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.
 
Old 07-06-2019, 03:46 PM   #26
ewlabonte
Member
 
Registered: Mar 2005
Distribution: Debian Stretch
Posts: 127

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by kilgoretrout View Post
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ubuntu MATE 15.04 Arrives With MATE Desktop 1.8.2 and MATE Tweak LXer Syndicated Linux News 0 05-15-2015 09:30 AM
[SOLVED] anyone else having update problems with Mint15 Mate & 16 Cinnamon or mate RC 1sweetwater! Linux Mint 2 08-05-2014 06:42 PM
[SOLVED] Mate switched to cinnamon wthout permission mint-13-mate littlejoe5 Linux Mint 7 05-08-2014 10:54 PM
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 06:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian

All times are GMT -5. The time now is 04:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration