March 30, 2023, 2:09am
I have a script to set the desktop wallpaper image that essentially does the following:
The script works fine if I run it manually. However, if I run it as a cron job, it returns the error:
An error occurred while attempting to set the Plasma wallpaper:
Not connected to D-Bus server
How can one change the desktop wallpaper using a cron job?
It’s probably because the cron job does not have access to your Dbus session. I thought Plasma already comes with a slideshow function, why not use that?
March 30, 2023, 12:41pm
It’s probably because the cron job does not have access to your Dbus session.
Is there any way to get that information and pass it to the script?
I thought Plasma already comes with a slideshow function, why not use that?
Right now that is what I am doing…
Ultimately, though, I would like to do this all using a script that I can transfer from one computer to another without having to do extra steps.
I believe that wallpaper setting are stored in ~/.config/plasma-org.kde.plasma.desktop-appletsrc.
Double checking, mine shows my different wallpaper settings across both my monitors and for all of my Activities.
April 3, 2023, 1:14pm
You could try a systemd service and timer that runs under your user session. That would likely be able to change it.
April 10, 2023, 10:00am
@claydoh and @Justin
~/.config/plasma-org.kde.plasma.desktop-appletsrc did the trick!
A systemd service sounds like an overengineered solution for this and I am not savvy enough to come up with that anyway.
But eventually I decided to go with the simpler solution of just using the Slideshow mode. My script will fetch a wallpaper image every night and place it in a directory.
April 10, 2023, 10:37am
For reference, the systemd solution would look something like this. The systemd timer essentially replaces the cron job:
Description=Periodically update the desktop background
# Trigger when hour and minute are 0 (i.e. midnight)
OnCalendar=0 0 * * *
Description=Update the desktop background with the latest image from somewhere
# Your script that fetches the image and sets it
Once you’ve created these two files, you just need to run
systemctl --user enable update-desktop.timer
to enable it.