Xfce Forum

Sub domains
 

You are not logged in.

#1 2007-04-19 08:34:26

ozroc
Member
Registered: 2007-02-03
Posts: 13

Changing wallpaper from bash script

Hello
I've been trying to change xfce's wallpaper from a bash script.
It's for a small program we're working on that makes a wallpaper from NASA's Astronomy picture of the day (and some other "picture of the day" sites).
I couldn't find a simple command for this like for other desktop environments, so had to do this:

    killall xfce-mcs-manager
    wait
    CHANGE="$(cat ~/.config/xfce4/mcs_settings/desktop.xml | grep path_0_0 | cut -d\" -f 6 | sed 's/\//\\\//g')"
    WITH="the_new_image_path"
    cat ~/.config/xfce4/mcs_settings/desktop.xml | sed 's/'$CHANGE'/'$WITH'/g' > desk2
    mv desk2 ~/.config/xfce4/mcs_settings/desktop.xml
    xfce-mcs-manager

I mean, I have to kill mcs-manager, grep desktop.xml looking for the actual wallpaper and change it's path with the new one and finally restart mcs-manager.

Isn't there a cleaner way for doing this? :?
Any ideas?


If anyone's interested in the "Picture Of the Day Wallpaper Generator", can visit http://ozrocberg.blogspot.com. For the moment the news are in Spanish but will be in English for the first release.

Offline

#2 2007-04-19 11:09:56

TomE
Member
Registered: 2005-02-05
Posts: 132

Re: Changing wallpaper from bash script

No need to kill mcs-manager, use xfdesktop --reload

    CHANGE="$(cat ~/.config/xfce4/mcs_settings/desktop.xml | grep path_0_0 | cut -d\" -f 6 | sed 's/\//\\\//g')"
    WITH="the_new_image_path"
    cat ~/.config/xfce4/mcs_settings/desktop.xml | sed 's/'$CHANGE'/'$WITH'/g' > desk2
    mv desk2 ~/.config/xfce4/mcs_settings/desktop.xml
        xfdesktop --reload

should work

Have a look here as well

Offline

#3 2007-04-19 18:55:07

ozroc
Member
Registered: 2007-02-03
Posts: 13

Re: Changing wallpaper from bash script

TomE wrote:

No need to kill mcs-manager, use xfdesktop --reload

    CHANGE="$(cat ~/.config/xfce4/mcs_settings/desktop.xml | grep path_0_0 | cut -d\" -f 6 | sed 's/\//\\\//g')"
    WITH="the_new_image_path"
    cat ~/.config/xfce4/mcs_settings/desktop.xml | sed 's/'$CHANGE'/'$WITH'/g' > desk2
    mv desk2 ~/.config/xfce4/mcs_settings/desktop.xml
        xfdesktop --reload

should work

Have a look here as well

Thank you, but...
No, I tried this but didn't work.  :oops:
It ignores the changes, and if I restart mcs-amanager after editing that file it overwrites my changes with the old configuration.

Offline

#4 2007-04-19 21:59:52

TomE
Member
Registered: 2005-02-05
Posts: 132

Re: Changing wallpaper from bash script

You could have xfdesktop use a link to your desktop image and just change the file it liks to and do a xfdesktop reload. If memory seves thats what my bash script in the link tread does.

Offline

#5 2007-04-21 07:32:35

Pindakoe
Member
From: NL
Registered: 2003-11-26
Posts: 116

Re: Changing wallpaper from bash script

I can reproduce ozroc's observation that an 'xfdesktop --reload' does in fact not reload the background image after an edit of ~/.config/xfce4/mcs_settings/desktop.xml. Strange, until I realised that my own experience with xfdesktop was restricted to use it to go to the next picture in a list of backdrops. I have consult the man-file which says for the -reload option:

Causes  an  already-running  instance of xfdesktop to reload all
its settings, including loading a new random backdrop if using a
backdrop list.

So, my understanding i that you can use the xfdesktop -reload, but only if you define your backdrop as a 'random' picture from a list (also defined in desktop.xml I believe; just go to desktop settings and create one). You could ofcourse create a one-file list... Note that for the list to work, it should start with a comment lint, I let it start with

echo "# xfce backdrop list" > $list  # Head of list for XFCE to recognize it

where $list is the name of the list file...

I can dig out the complete script if you are interested (may even be posted here a long time ago). And before you ask: it is not possible afaik to get from xfdesktop (or one of the config files) what the name is of the currently displayed picture.

Offline

#6 2007-04-24 18:56:16

ozroc
Member
Registered: 2007-02-03
Posts: 13

Re: Changing wallpaper from bash script

TomE wrote:

You could have xfdesktop use a link to your desktop image and just change the file it liks to and do a xfdesktop reload. If memory seves thats what my bash script in the link tread does.

That works once you have configured the wallpaper to a certain (known) picture. You change the picture and restart xfdesktop. But my script has to change your previous configuration from any wallpaper picture you had configured to the new one (once this is done, just restarting will work).

My script works, but it's stupid not to have a simpler way to change XFCE's wallpaper.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.015 seconds, 7 queries executed - Memory usage: 539.9 KiB (Peak: 541.18 KiB) ]