#!/usr/local/bin/perl
#=======================================================================
# kEsetroot  - KDE Esetroot integration for Eterm
#
# Copyright (C) 1999 - 2000  Dax T. Games
#                           (dgames@isoc.net)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#=======================================================================
# Written by Dax Games <dgames@isoc.net>
# Sets root pixmap for Eterm transparency.

$HOME = $ENV{'HOME'};
$KDEDIR = $ENV{'KDEDIR'};
open (in,"$HOME/.kde/share/config/desktop0rc");

while (<in>) {
	if ($_ =~ /^Wallpaper=(.*)/i) {
		if (-e $1) {
			$PixMap = $1
			#system("/usr/bin/Esetroot -display :0 $1");
		}
		elsif (-e "$KDEDIR/share/wallpapers/$1") {
			$PixMap = "$KDEDIR/share/wallpapers/$1"
			#system("/usr/bin/Esetroot -display :0 $KDEDIR/share/wallpapers/$1");		
		}
		else { 
			exit(1);
		}
	}
	elsif ($_ =~ /^WallpaperMode=(.*)/i) {
		$WallpaperMode = uc($1);
		if ($WallpaperMode eq "TILED") {
			$PixMapMode = ""
		}
		elsif ($WallpaperMode eq "CENTRED") {
			$PixMapMode = "-center ";
		}
		elsif ($WallpaperMode eq "SCALED") {
			$PixMapMode = "-scale ";
		}
	}

}
close (in);

system("/usr/local/bin/Esetroot $PixMapMode $PixMap");

if (!-e "$HOME/Desktop/Autostart/kEsetroot.kdelnk") {
	print "Do you want to start kEsetroot when KDE starts? y/n [y] ";
	$AutostartYORN = (<>);
	chomp $AutostartYORN;

	if ($AutostartYORN = "" or $AutostartYORN = "Y") {
		open (out, ">$HOME/Desktop/Autostart/kEsetroot.kdelnk");
		print out "\# KDE Config File\n";
		print out "[KDE Desktop Entry]\n";
		print out "Name[fi]=Sovellus\n";
		print out "Comment[C]=Set root pixmap for Eterm transparency\n";
		print out "SwallowTitle=\n";
		print out "SwallowExec=\n";
		print out "Name[ru]=ðÒÉÌÏÖÅÎÉÅ\n";
		print out "BinaryPattern=\n";
		print out "Name[hr]=Program\n";
		print out "Name[sl]=Uporabni¹ki program\n";
		print out "Name[pl]=Aplikacja\n";
		print out "Name=Application\n";
		print out "Name[ca]=Aplicacions\n";
		print out "Name[it]=Applicazione\n";
		print out "Name[da]=Anvendelse\n";
		print out "Name[C]=KDE Esetroot\n";
		print out "MimeType=\n";
		print out "Name[de]=Anwendung\n";
		print out "Name[ja]=¥¢¥×¥ê¥±¡¼¥·¥ç¥ó\n";
		print out "Exec=kEsetroot\n";
		print out "Name[cs]=Aplikace\n";
		print out "Name[sv]=Program\n";
		print out "Icon=kwm.xpm\n";
		print out "TerminalOptions=\n";
		print out "Name[sk]=Aplikácia\n";
		print out "Path=\n";
		print out "Name[pt_BR]=Aplicativo\n";
		print out "Type=Application\n";
		print out "Name[es]=Aplicaciones\n";
		print out "Name[is]=Forrit\n";
		print out "Name[pt]=Aplicação\n";
		print out "Terminal=0\n";
		print out "Name[no]=Applikasjon\n";
		print out "Name[hu]=Applikáció\n";
		print out "Name[ro]=Aplicaþie\n";
		close(out);
	}
}


