#!/usr/local/bin/perl -w # # Copyright (C) 2004 Chatchawan Wongsiriprasert # # $Id: xplanet-gnome.pl,v 1.2 2004/07/03 03:05:27 cws Exp $ # use strict; my $DELAY=30 * 60; my $PREFIX="/tmp"; my $OUTPUT="xplanetBkg.png"; my $GEOMETRY="1400x1050"; my $LONGITUDE=105; my $LATITUDE=15; my $LABEL_PARAM="-label -labelpos -15+40"; #We need 2 names for the image, it #seems that gnome will not update background image if we don't change the #file name. my $out1 = "$PREFIX/1-$OUTPUT"; my $out2 = "$PREFIX/2-$OUTPUT"; my $tmp_out = "$PREFIX/tmp-$OUTPUT"; setpriority(0,0,10); while ( 1 ) { my @t = gmtime(); my $l = 105 - 360 * ($t[2]*60+$t[1])/1440; `xplanet -num_times 1 -output "$tmp_out" -geometry $GEOMETRY -longitude $l -latitude $LATITUDE $LABEL_PARAM`; if ( -f $tmp_out ) { my $s = `gconftool-2 -g /desktop/gnome/background/picture_filename`; chomp($s); my $out; if ( $s eq $out2 ) { $out = $out1; } else { $out = $out2; } if ( $s eq $out1 || $s eq $out2 ) { unlink($s); } rename($tmp_out,$out); `gconftool-2 -t str -s /desktop/gnome/background/picture_filename \"$out\"` } @t = gmtime(); my $s = ($t[1] % ($DELAY/60) ) * 60 + $t[0]; sleep($DELAY - $s); }