tip of the month in LXF66

Comments, suggestions and questions about Linux Format magazine and the coverdiscs

Moderators: ChrisThornett, LXF moderators

tip of the month in LXF66

Postby zsiga » Wed Dec 07, 2005 7:19 am

Hey all, I'm a bit of a linux newcomer as you'll soon learn and I was having trouble getting the command image=`gawk -F\"'/href="image/{print$2;exit;}'$PGE` to work in the nasa desktop-a-day tip....everything was fine until that point. Also, if I don't use KDE and don't have dcop is there away to get the same result in gnome?
-Thanks
zsiga
 
Posts: 2
Joined: Wed Dec 07, 2005 7:12 am

RE: tip of the month in LXF66

Postby graham » Thu Dec 08, 2005 9:06 am

Morning!

Here's the script that I use at the moment (for KDE):

Code: Select all
#!/bin/bash
TMP="/tmp"
SRC="http://antwrp.gsfc.nasa.gov/apod/"
PGE="astropix.html"
cd ${TMP}
wget --quiet $SRC$PGE
image=`gawk -F \" '/href="image/ { print $2; exit; }' $PGE`
wget --quiet $SRC$image
filename="${image##*/}"
cp -rf $TMP/$filename $HOME/.kde/share/background
dcop kdesktop KBackgroundIface setBackgroundEnabled false
dcop kdesktop KBackgroundIface setWallpaper $HOME/.kde/share/background 6
dcop kdesktop KBackgroundIface setBackgroundEnabled true
rm -rf $TMP/$filename
rm -rf $TMP/$PGE


To get this functionality in Gnome, you need to use something like gconftool-2 to change the background. For example, the following will change the background to /home/graham/background.png :

Code: Select all
gconftool-2 --type str ---set /desktop/gnome/background/picture_filename /home/graham/background.png


It should be quite straighforward to adapt the KDE script, and you'll need to use 'cron' to run the script at a certain time. Let us know if you have a problem - if you get it to work, it would be great if you could post your script here!
User avatar
graham
Site admin
 
Posts: 37
Joined: Tue Apr 12, 2005 9:31 am

RE: tip of the month in LXF66

Postby firefox » Fri Dec 09, 2005 4:12 pm

That's quite a scary avitar, graham. Is it from something in particular? :o
firefox
 
Posts: 64
Joined: Mon Apr 11, 2005 11:21 am

Postby zsiga » Sat Dec 10, 2005 10:41 am

Well, due to a bit of overlooking the obvious I just got it.
Code: Select all

#!/bin/bash
TMP="/tmp"
SRC="http://antwrp.gsfc.nasa.gov/apod/"
PGE="astropix.html"
cd ${TMP}
wget --quiet $SRC$PGE
image=`gawk -F \" '/href="image/ { print $2; exit; }' $PGE`
wget --quiet $SRC$image
filename="${image##*/}"
cp -rf $TMP/$filename $HOME/.gnome2/share/background.png
gconftool-2 --set /desktop/gnome/background/image_filename $HOME/.gnome2/share/background.png  --type str
gconftool-2 --type str --set /desktop/gnome/background/picture_options "stretched"
rm -rf $TMP/$filename
rm -rf $TMP/$PGE
 


The picture_options had to be set as well.

Thanks Graham!
zsiga
 
Posts: 2
Joined: Wed Dec 07, 2005 7:12 am


Return to Magazine and coverdiscs

Who is online

Users browsing this forum: No registered users and 0 guests