You are not logged in.
Pages: 1
Is there a way to change the desktop background automatically?  In 4.2 I used xfdesktop in cron and had it change every 30 minutes.  This no longer works for me.  I have done a search here and read through the wiki but cannot find an answer.  I use Zenwalk with Xfce 4.6.
Thanks for any help.
john
Offline
John,
It seems that the command
xfdesktop --reload
no-longer changes the desktop background in XFCE4.6, which as you say is a bit of a nuisance, since it was a useful tool either in cron or as a Program Launcher. I came across the following script, which does the job just as well.
#!/bin/sh
MONITOR=${1:-0}
PROPERTY="/backdrop/screen0/monitor${MONITOR}/image-path"
IMAGE_PATH=`xfconf-query -c xfce4-desktop -p ${PROPERTY}`
xfconf-query -c xfce4-desktop -p ${PROPERTY} -s ""
xfconf-query -c xfce4-desktop -p ${PROPERTY} -s "${IMAGE_PATH}"
You set up your image list through Desktop as before and then run this script against the list, and you have your changeable backgrounds back. I found this script in Mike Massonnet's Blog at
http://mmassonnet.blogspot.com/2009/03/ … round.html
The current repository for Zenwalk 6.0 has some upgrades for the XFCE packages, that fix a few of the problems. You might want to download these as well
Regards
Michael
Offline
Mike,
Thanks, I will check out the link and try the script. I thought I would post over here rather than at Zenwalk forums since it is an Xfce issue. It has been a week or 2 since I upgraded so I will do that shortly. Thanks for your help.
john
Offline
Michael,
Sorry about the "Mike" in the last post. My oldest son is named Michael and I always call him Mike and I guess I typed it without thinking ;D
I copied the code and saved as bgchanger.sh. When I run it in a terminal it changes the background, not very smoothly, but it changes. I put it in cron to run every thirty minutes and it hasn't changed yet. I am pretty sure I have it correct because the other cron job to back up a file nightly works every night.
I did upgrade as you suggested but it hasn't caused any changes that I can see anywhere.
I am not big on scripting so can I ask a question? In the 3d line should /image-path be changed to the actual path to the background folder? I didn't change it and it works. Maybe a stupid question but I am learning
Thanks,
john
Offline
jbs, you'll probably have to export the DISPLAY in the script (export DISPLAY=":0.0") and the script should work
Offline
John,
No worries, mate, I answer to both and to "Hey You!!" if distracted ;D
The script uses a feature that is new to XFCE4.6, which is xfconf with its associated command xfconfig-query and the daemon xconfd. Basically, the xfconf system controls the "look and feel" of the computer environmant in real time, on a per-user basis. This means that the "look and feel" of each users environment on the computer can be set up differently. To do this, xconf relies on configuration files that are in the ~/.config/xfce4/xconf/xfce-perchannel-xml directory, which contains a number of xml files.
NOTE: I normally have a copy of the contents of this directory somewhere else in my home directory in case of accidents.
Xfconf can be thought to be working with two entities ..... channels, which are the individual files in this directory and ..... properties, which are defined in each of these files and given values. A property is tied to a particular channel. Admittedly, the xml files are tedious to read through, so it is a lot easier and more understandable to use the GUI interface run from a terminal as the normal user
xfce4-settings-editor &
In the left hand panel you can see the list of all of the channels and in the right -hand panel there is a list of the values for the properties in that channel. Now the channel we are interested in at the moment. is the xfce4-desktop channel (this is the "-c xfce4-desktop" in the script). If you click on that you will see that there are three top level properties shown in the right-hand panel, one of which is backdrop. If you click on that you will probably go down through the sub properties screen0. then monitor0, until you come to a list of actual properties along with their type and their current vaule. One of these properties is "image-path".
So to finally answer the first of your questions. in the line of the script
PROPERTY="/backdrop/screen0/monitor${MONITOR}/image-path"
we are not referring to an absolute path name, as one might expect, but, rather confusingly, this is the way that the poperty name is set out. So in the channel xfce4-desktop you have a property "/backdrop/screen0/monitor${MONITOR}/image-path" of type "string" and whose value, and absolute pathname you can see as its vaule and which will refer to the backdrop list of images that you created for your various backgrounds
The next line of the code will set the value of the property "/backdrop/screen0/monitor${MONITOR}/image-path" to null
xfconf-query -c xfce4-desktop -p ${PROPERTY} -s ""
with the -s "" arguement of the command.
The last line of the code sets the property value to the absolute pathname of backdrop list, and in practice reads a random reference to a background image from your list and refreshes your background with it
The xconfd daemon continually monitors the xfconf properties for any changes. You can see this happen as you change your background with the following command and output, where we run the monitor on the xfce4-desktop channel
xfconf-query --monitor -c xfce4-desktop
Start monitoring channel 'xfce4-desktop':
------------------------------------------------
Property '/backdrop/screen0/monitor0/image-path' changed
Property '/backdrop/screen0/monitor0/image-path' changed
The two references to to the property being changes are the script first setting the value of the '/backdrop/screen0/monitor0/image-path' to null and then setting it back absolute pathname of your backdrop list.
This in itself is obviously not enough, since all we have done is to change the value of the property. This is where the "magic" comes in, because xfconf works hand in hand with dbus and dbus controls your physical system. I dont fully understand this in detail yet so I'll spare you my floundering around with a detailed explanation. But again you can watch what happens when you change your background, by watching the output of the dbus-monitor command, run in a terminal as a normal user. The slightly edited output of this command, when I change my background is as follows
string "type='signal',sender='org.xfce.Xfconf',path='/org/xfce/Xfconf',interface='org.xfce.Xfconf'"
method call sender=:1.235 -> dest=org.freedesktop.DBus serial=4 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=GetNameOwner
string "org.xfce.Xfconf"
method call sender=:1.235 -> dest=org.xfce.Xfconf serial=5 path=/org/xfce/Xfconf; interface=org.xfce.Xfconf; member=PropertyExists
string "xfce4-desktop"
string "/backdrop/screen0/monitor0/image-path"
method return sender=:1.1 -> dest=:1.235 reply_serial=5
boolean true
method call sender=:1.235 -> dest=org.xfce.Xfconf serial=6 path=/org/xfce/Xfconf; interface=org.xfce.Xfconf; member=GetProperty
string "xfce4-desktop"
string "/backdrop/screen0/monitor0/image-path"
method return sender=:1.1 -> dest=:1.235 reply_serial=6
variant string ""
method call sender=:1.235 -> dest=org.xfce.Xfconf serial=7 path=/org/xfce/Xfconf; interface=org.xfce.Xfconf; member=SetProperty
string "xfce4-desktop"
string "/backdrop/screen0/monitor0/image-path"
variant string "/home/<username>/.config/xfce4/desktop/backdrop.list"
method return sender=:1.1 -> dest=:1.235 reply_serial=7
signal sender=:1.1 -> dest=(null destination) serial=1059 path=/org/xfce/Xfconf; interface=org.xfce.Xfconf; member=PropertyChanged
string "xfce4-desktop"
string "/backdrop/screen0/monitor0/image-path"
variant string "/home/<username>/.config/xfce4/desktop/backdrop.list"
signal sender=org.freedesktop.DBus -> dest=(null destination) serial=12 path=/org/freedesktop/DBus; interface=org.freedesktop.DBus; member=NameOwnerChanged
As you can see there's rather a lot happening. But basically, the dbus determines that the property exists to begin with and its value, notes that its been set to null and then notes it been changed again to the backdrop list and applies it, as it would if you were using the Desktop Setting application and setting a new background image.
So to answer the next question, given the amount that goes on to change your background, its probably not suprising that its sluggish, so much as it ever manages to do it at all. But now at least you have the tools to watch it happen and to do the forensics if it doesn't
In terms of the cron, the answer is more subtle. The cron is a system process and usually operates in the depths of your computer and you don't see anything thats happening. The xfconf-query command, as I've explained works very much on the surface of your system and controls the look and feel of your interface into the computer itself. Now if you run this script in cron you are probably going to have to run it as your own username cron, so that it works with your own envirnment settings ....ie where is the ~/.config etc and also you have to tell it where to send its output, because cron isnt usually a visible command interface. So therefore, as s0ulslack suggested, setting the DISPLAY variable will tell cron, xfconf-query and dbus where its supposed to do all of this. This is one of those old hangovers from the early days of UNIX and X, where cron and other commands would run on a central server and you had to tell it what display and computer to send the graphical output to, otherwise you never got it. Your computer may only have one monitor but your operating system dreams of the glory days of old, when it had empires of displays under its control, so you have to pander its memories of grandeurs past.
PLEASE NOTE I have tried not to refer to "resetting" the value of the property. In xfconf-query the --reset has a counter-intuitive meaning. It DOES NOT mean reset the value of the property to its previous value. It means REMOVE the property altogether!!! Having been caught by this myself whilst experimenting, I was lucky, or paranoid enough, to have a copy of my ~/.config elsewher on the system, so I could refer to it to get the values and strings. so I could re-create the property.
Sorry this explanation has been a bit long, but the documentation relating to all of this new stuff is sparse verging on the non-existent, so I thought it was worthwhile to go into some detail.
Regards
Michael
BTW I have no idea what the new xfce packages "fixed" but it "may" have fixed the display resolution bug though this is under discussion in the Zenwalk Forum .... MP.
Offline
Wow, that took me a couple of minutes to read and a bit more to digest. Thanks for the explanation. I never expected that much but it does explain a lot. After opening the settings manager I understand where the info in the script comes from. I would never be able to write something like that but at least I understand now what it means and what it affects. I was concerned that I had misread the script and was supposed to put in an actual path. Glad I waited for the explanation and didn't change anything.
As for the cron, I made the change in the script but it still doesn't change the background. I will play around with it some more. Never mind. THE BACKGROUND JUST CHANGED!!! Sorry for the yelling but while I was typing this the background just changed. So it does work now thanks to you and s0ulslack.
Now I have my backgrounds changing and I actually understand what I did. Wow. Thanks again for your time to explain all of this.
john
Offline
Pages: 1
[ Generated in 0.009 seconds, 7 queries executed - Memory usage: 588.1 KiB (Peak: 604.95 KiB) ]