0

I've written a little script createCountdownWallpaper.py that is supposed to re-render the wallpaper /tmp/wallpaper.png every few minutes, and a script setWallpaper.sh that looks as follows:

#!/bin/bash
cd /home/path/to/countdown
/usr/bin/python3.5 createCountdownWallpaper.py

xfconf-query  \
  --channel xfce4-desktop \
  --property /backdrop/screen0/monitor0/workspace0/last-image \
  --set /tmp/wallpaper.png

The channels and property have been selected using -m flag of xfconf-query, as described in this answer. It works when run from the terminal. However, when run from cron, it seems to have no effect. Crontab:

SHELL=/bin/bash

*/1 * * * * /home/path/to/countdown/setWallpaper.sh 2>/tmp/cron_errors.txt

I've also tried sourcing various .bashrc and .profile scripts and setting environment variables like

DBUS_SESSION_BUS_ADDRESS=unix:abstract=tmp/dbus-r4nd0MjunK

but it didn't help either.

2 Answers 2

1

Execute this before running xfconf-query:

PID=$(echo $(ps -C xfce4-session -o pid=))                                      
export $(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ)
0

The following combination seemed to work, it re-renders and changes the background every minute.

SHELL=/bin/bash

*/1 * * * * yourUsername source $HOME/.profile ; source $HOME/.bashrc; env DISPLAY=:0.0 /home/path/to/countdown/setWallpaper.sh 2>/tmp/cron_errors.txt

Hints:

  • DBUS_SESSION_BUS_ADDRESS does not seem to matter
  • The Folder: /tmp setting in the GUI "Desktop" menu does matter
  • The automatic changing of wallpapers every N minutes must be deactivated in the XFCE-gui for wallpaper settings.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .