LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   a script to change wallpaper (https://www.linuxquestions.org/questions/linux-newbie-8/a-script-to-change-wallpaper-776587/)

repo 12-23-2009 04:26 AM

Please post the script you use., and the entry in cron

Agrouf 12-23-2009 04:30 AM

Also, check that the gconftool-2 command is indeed executed and with which arguments.
You can do that with the echo command redirected to a file.
Code:

echo "I execute the gconftool-2 command with arguments: --type string --set /desktop/gnome/background/picture_filename $pictdir/${fnme[${i}]}" >/tmp/myscript.log
put that code right after the call to gconftool-2

sumeet inani 12-23-2009 05:55 AM

Here is the output

I execute the gconftool-2 command with arguments: --type string --set /desktop/gnome/background/picture_filename /home/lxuser/wp/1.jpg at Wed Dec 23 17:18:01 IST 2009

Please Note the variable was wp_fn so I used $wp_fn in double quotes & also added `date` to expression in double quotes.

the annoying thing is when I check string using
gconf-editor or gcontool-2 then value has not changed & equals default.

sumeet inani 12-23-2009 05:58 AM

Here is the script for all ubuntu GNOME users to change wallpaper every 5 minutes ( tested in ubuntu 8.04 ).
All you have to do is copy desired wallpaper(jpg format) to `/Pictures & rename then as 0,1,2...
Code:

#!/bin/bash
if [ -e ~/Pictures/.int.txt ]; then
echo 0 > /dev/null
else
echo 0 > ~/Pictures/.int.txt
fi

i=`head ~/Pictures/.int.txt` #get the content of the file

#if greater than 18, then sets back i to 0.
if [ $i -gt 18 ]; then
    let i=0
fi

wp_fn=~/Pictures/$i.jpg #set the name of the wallpaper file

gconftool-2 -t str -s /desktop/gnome/background/picture_filename $wp_fn

#after finished, increment the value of i
let i=i+1;
echo "$i" > ~/Pictures/.int.txt

Save above file as script in ~/Pictures,
Make it executable using 'chmod +x ~/Pictures/script'
Add following entry to cron using 'crontab -e'
*/5 * * * * ~/Pictures/script
You can verify by 'crontab -l'
This will change wallpaper every 5 minutes.
NOTE
You can remove extension from all wallpaper files & also remove .jpg from script then you can use any image format ( tested with png ).

If you find this post useful then thank me by pressing thumbs up button.Thank You.

repo 12-23-2009 06:00 AM

Quote:

/desktop/gnome/background/picture_filename
shouldn't that be
Quote:

/home/user/.gconf/desktop/gnome/background/picture_filename
Could you please post the whole script and the crontab entry you use?

repo 12-23-2009 06:04 AM

try to use
Quote:

* * * * * /home/lxuser/wp/change-script
Are you running the cron as user lxuser?

BTW, if there are problems with cron, it will sent a mail with the errormessages.
or look in the logfiles

sumeet inani 12-23-2009 06:11 AM

Done but no effect.
Is it possible that desktop wallpaper is locked.
Also ran
mail
But got no message
I also found that
/home/lxuser/.gconf/desktop/gnome/background/%gconf.xml
is also changing as desired but screen does not refresh.Why ?

DrLove73 12-23-2009 06:44 AM

One of MANY MANY bugs in Ubuntu's?

Agrouf 12-23-2009 07:05 AM

Quote:

Originally Posted by repo (Post 3802314)
shouldn't that be

No, it's a gconf entry, not a filename.
sumeet inani:
I saw you use /home/path instead of exporting $HOME as I suggested.
You should not. gconftool-2 uses $HOME/.gconf and if $HOME is not set, it won't work.
DO use that code at the start of your script:
Code:

export HOME=/home/myuser

repo 12-23-2009 07:07 AM

Hi,

Take a look at
http://www.pubbs.net/gnome/200910/3988/

Agrouf 12-23-2009 07:14 AM

Quote:

Originally Posted by DrLove73 (Post 3802350)
One of MANY MANY bugs in Ubuntu's?

I am pretty sure it is not a bug and more likely linked to the environment variables that are not set when running from cron.

repo 12-23-2009 07:26 AM

Quote:

Originally Posted by DrLove73 (Post 3802350)
One of MANY MANY bugs in Ubuntu's?

Its a problem with GNOME, not ubuntu or whatever distro you use
see
http://www.pubbs.net/gnome/200910/3988/

Agrouf 12-23-2009 07:42 AM

Quote:

Originally Posted by repo (Post 3802405)
Its a problem with GNOME, not ubuntu or whatever distro you use
see
http://www.pubbs.net/gnome/200910/3988/

I've read the link and I still believe it is an environment problem.
To test it, I suggest doing that:
Code:

env | sed "s/^/export /g" | sed "s/=/=\"/" | sed "s/$/\"/g"  >/tmp/env.sh
chmod a+x /tmp/env.sh

and adding that at the beginning of the script:
Code:

. /tmp/env.sh

sumeet inani 12-28-2009 11:17 PM

As i have said that even if I mention full address without using ~ or $HOME etc. then also wallpaper does not change in ubuntu 9.04 though it does in ubuntu 8.04.
So I think repo is right.
I will also modify script a little bit in previous post so that atleast ubuntu 8.04 users can store all their wallpaper files numbered 0.jpg,1.jpg,.. and script in ~/Pictures.

Agrouf 12-29-2009 05:26 AM

Edit: duplicate post


All times are GMT -5. The time now is 03:02 PM.