2

I tried to set up wallpaper change via cron in /etc/crontab, but I failed.

DISPLAY env set directly / before cmd, but still it's not working:

DISPLAY=:0.0
* * * * * ad   env DISPLAY=:0.0 /usr/bin/awsetbg -a -r /home/ad/img/beauty/
* * * * * ad   DISPLAY=:0.0 /usr/bin/awsetbg -a -r /home/ad/img/beauty/
* * * * * ad   export DISPLAY=:0.0; /usr/bin/awsetbg -a -r /home/ad/img/beauty/

su - user -c "cmd" worked:

* * * * * root su - ad -c "DISPLAY=:0.0 /usr/bin/awsetbg -a -r /home/ad/img/beauty/"

Now I'm using user's crontab (crontab -e) which works fine:

*/10 * * * * DISPLAY=:0.0 /usr/bin/awsetbg -a -r /home/ad/img/beauty/

What else do I have to set?

cron's env:

MAILTO=root
SHELL=/bin/bash
USER=ad
PATH=/sbin:/bin:/usr/sbin:/usr/bin
PWD=/
SHLVL=1
HOME=/
LOGNAME=ad
DISPLAY=:0.0   # same result for DISPLAY=:0
_=/bin/env

Using vixie-cron 4.1-r1 on Gentoo.

A.D.
  • 950

2 Answers2

1

I guess it's changing HOME=/ to HOME=/home/ad.

1

I totally forgot that awsetbg is just shell script which uses $HOME variable.

  awsetbg - awesome wrapper tool to set background

So HOME needs to be set.

* * * * * ad   DISPLAY=:0,HOME=/home/ad /usr/bin/awsetbg -a -r /home/ad/img/beauty/

If you will use directly some app, it will work just with DISPLAY env:

* * * * * ad   DISPLAY=:0 feh --bg-max --randomize /home/ad/img/beauty/
A.D.
  • 950