You are not logged in.
Hi there!
My first thread here.
I run different Linux distros all with XFCE desktop, in a half dozen machines (most in dual- or multibooting) I usually have on my desk and I would like them all to start up to a same desktop background.
My problem so far has been that I manually must change the background of my machines a few times a day - which is no problem at all- and since I usually work so late as to be completely exhausted I always forget to change the desktop background to my ideal "default" image - which is the problem because when I start up again it will show some other background than the desired "default".
I have googled for some script to be run at startup or preferably at shutdown that would accomplish this goal and having had no success tried to get help at the Linux Questions forum where I usually get fantastic support, but had no luck this time..
I have now finally found XFCE forum, and would like to start here by asking 2 questions:
1 - which logic determines which is the first image at startup when one does not choose slide showing and random order before shutting down ? (I suppose it would be the then current background at the last shutdown time, but by now I am not sure).
2 - which logic determines which is the first image at startup when I do choose slide showing, no random order before shutting down? (I have read some where that it is the first image "in the folder" - which I assume to be "/usr/share/ackgrounds/xfce" in my case. But I am not sure whether it will be the first when ordered by name, size, date or whichever criterion).
I have gone through all links filtered by "script desktop background" in your search engine and found quite a few very interesting threads, but the most recent was from 2015 and the oldest from 2007. Should I not be afraid of following their tips ?
If anyone wishes to see how difficult I have in explaining myself, here is the link to the Linux Questions thread: https://www.linuxquestions.org/question … 175747449/
Last edited by fredmyra (2025-04-30 21:10:12)
Offline
Hello and welcome.
1 - which logic determines which is the first image at startup when one does not choose slide showing and random order before shutting down ? (I suppose it would be the then current background at the last shutdown time, but by now I am not sure).
The setting for the last used wallpaper is stored in the xfconfd database. It will be reloaded on xfdesktop startup. The see the contents of the xfce4-desktop channel in he xfconf database, you can:
xfconf-query -c xfce4-desktop -lv
...or look at the xfce4-settings-editor.
2 - which logic determines which is the first image at startup when I do choose slide showing, no random order before shutting down? (I have read some where that it is the first image "in the folder" - which I assume to be "/usr/share/ackgrounds/xfce" in my case. But I am not sure whether it will be the first when ordered by name, size, date or whichever criterion).
Here is the code. If I'm reading this properly, it saves the last image used, sets that as the first and randomly orders the other images in the folder.
I have googled for some script to be run at startup or preferably at shutdown that would accomplish this goal and having had no success tried to get help at the Linux Questions forum where I usually get fantastic support, but had no luck this time..
You could create a script that runs xfconf-query to change the background to your desired image. Something like:
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitorVirtual-1/workspace0/last-image -s "image_file"
...note that the property setting will be probably be different for you. To get the actual property being used, run the following command in a terminal window:
xfconf-query -c xfce4-desktop -mv
...and manually change the wallpaper - the path will be output in the terminal window. This is the path you would use.
You can then create an entry in Settings Manager > Application Autostart to run this command. You click on the "Trigger" column entry to select login or logout.
Try this first to see if it works. If setting it on login, you may need to add a delay to the script so that xfdesktop doesn't overwrite your setting with its default behaviour.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Thanks @ToZ for clear, precise answer. Exactly what I had been looking for.
It will be sometime before I can try to put it into practice, but I will report when I do.
Offline
Well, it does work. But.
I am not very proficient at these things, it is actually the first time I dare making a script in Linux, used to do it on mac a couple decades ago.
The present symptom:
When I start the computer it boots to lightdm, where it shows the image designed as "background" in '/etc/lightdm/lightdm-gtk-greeter.conf' for almost a second followed by the last image in the previous session as the new background to the login screen. Upon logging in it waits a few seconds still with the last image of the previous session, then it goes black for a longer period, then it shows the last image of the previous session again, briefly, then finally settles to the desired image.
What I have done:
arthur-lifebooku749:[arthur]:~$ xfconf-query -c xfce4-desktop -mv
Start monitoring channel "xfce4-desktop":
set: /backdrop/screen0/monitoreDP1/workspace0/last-image (/usr/share/backgrounds/xfce/cumberlandfalls2.jpg)
My /home/arthur/myScripts/backdrop_change.sh:
#!/bin/bash
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP1/workspace0/last->
echo " changing Backdrop"
sleep 3
Permissions:
arthur-lifebooku749:[arthur]:~$ nano -w myScripts/backdrop_change.sh
arthur-lifebooku749:[arthur]:~$ ls -l myScripts
total 4
-rwxrwx--- 1 arthur arthur 179 2 maj 16.39 backdrop_change.sh
arthur-lifebooku749:[arthur]:~$
I suspect I am missing some minor detail somewhere. I hope so.
Added later 55 min 25 s:
My Settings Manager:
https://www.flickr.com/photos/10779179@ … 0325798980
Offline
Your script should look like this:
#!/bin/bash
echo " changing Backdrop"
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP1/workspace0/last-image -s /usr/share/backgrounds/xfce/cumberlandfalls2.jpg
Hopefully it works on shutdown before the X session is closed. If not, try it on login.
Mark solved threads as [SOLVED] to make it easier for others to find solutions.
--- How To Ask For Help | FAQ | Developer Wiki | Community | Contribute ---
Offline
Your script should look like this:
#!/bin/bash echo " changing Backdrop" xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP1/workspace0/last-image -s /usr/share/backgrounds/xfce/cumberlandfalls2.jpg
Sorry about that, I goofed, copying/pasting from nano and lost part of the script, but I think the script was correct, with
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP1/workspace0/last-image -s /usr/share/backgrounds/xfce/Butterfly.jpg
Trying this version
#!/bin/bash
xfconf-query -c xfce4-desktop -p /backdrop/screen0/monitoreDP1/workspace0/last-image -s /usr/share/backgrounds/xfce/Butterfly.jpg
echo " changing Backdrop"
sleep 10
$(sudo openrc-shutdown -p now)
without having the script in Startup Applications and inactivating Slide show and random order in the desktop settings works perfectly, although only from the terminal.
If I click on the desktop link to the script it changes the backdrop, but does not shutdown.
I can probably live with this even if it is not the ideal solution.
About Permissions:
arthur-lifebooku749:[arthur]:~$ ls -l Desktop
total 48
lrwxrwxrwx 1 arthur arthur 41 2 maj 22.36 backdrop_change.sh -> /home/arthur/myScripts/backdrop_change.sh
and
arthur-lifebooku749:[arthur]:~$ ls -l myScripts
total 4
-rwxrwx--- 1 arthur arthur 211 3 maj 01.40 backdrop_change.sh
but if I right-click click on their links and choose /Properties/Permissions, both show as root:wheel; read,write.
I am now trying to find a way to run the script properly by clicking on some item on the desktop or on some menu (preferably the Applications Menu)
Thanks for your support.
Offline
[ Generated in 0.017 seconds, 7 queries executed - Memory usage: 580.09 KiB (Peak: 596.94 KiB) ]