[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Autorn of program on KDE login?



On Sun, Jan 23, 2005 at 09:44:16PM +0000, Peter Nuttall wrote:
> On Sunday 23 Jan 2005 15:49, stan wrote:
> > On Sun, Jan 23, 2005 at 02:45:21PM +0000, Peter Nuttall wrote:
> > > On Sunday 23 Jan 2005 14:19, stan wrote:
> > > > I'm trying to convert a setup from Gnome 1.4 to something current. So
> > > > far I'm leaning in the direction of KDE, as it seems more
> > > > customizable than the current flavor of Gnome (which BTW sunrises
> > > > me).
> > > >
> > > > In any case, I have a perl script that picks a random image to use
> > > > for a desktop background. In Gnome 1.4, I'm able to configure this
> > > > program to be run automatically at startup.
> > > >
> > > > So far, I have not found a way to do this in KDE. Is there some way I
> > > > can do this?
> > >
> > > Yeah,
> >
> > Thanks for the quick reply.
> >
> > I'm still having a bit of a problem with this, though.
> >
> > > Put the program in .kde/Autostart/ then it will run on startup.
> >
> > I did that, and it pops up during startup, but then it gets overwritten
> > with a color fill.
> >
> > > You know that this can be done by kde in at least 3.3 don't you? Its in
> > > control/appearance & Themes/Background under slideshow.
> >
> > I want to use a whole directory, that gets update fairly often, so I
> > don't _think_ is the appropriate answer. Am I wrong?
> >
> > I've added the script under Appearance nd Themes -> background ->
> > advanced. This causes a 2n'd random image to appear during startup (yes I
> > will remove it from Autostart), but it _still_ gets overwritten by a
> > color fill. I've tries all 3 choices of select buttons (picture, no
> > picture, and slide show0, but at the end of the desktop startup I still
> > get a color fill that overrides the images.
> >
> > What am I doing wrong?
> >
> 
> Ok, You have three options
> 
> 1) this .xinitrc thing.

OK, I just tried this. The result is that I see a random omage pop up
breifly, then it gets overwritn by the (presently black) bachround color I
have slected. I can't figure out how to tell kde to _not_ use a color.

> 
> 2) the kde slideshow feature. 

> This has the problem that you can't add pictures to the dir after startup. 
> This should be filed as a bug at bugs.kde.org
> 
Right.

> 3) running your script from the advanced option. 

Tha's what I'm trying to do. I've select "no picture"m but I cannot figure
out how to _not_ get the background color.
> 
> I'm not sure how this option works or what it is supposed to output. I'm 
> also worried by this colour fill you are getting. My guess is that your 
> perl script outputs some X commands that are being overwritten by kde. 
> Could you post it please?
> 
Certainly. BTW I would like to credit the orignal author on this, but i've
lost that inormation :-(


#!/usr/bin/perl

#  randbg - select a background for the root window
#  981107 - jt fecit

#  Assumptions:
    #  The backgrounds directory is in env var $BACKGROUNDS

#  Get display information

my $screenwidth, $screenheight;
$screenwidth = 1152;
$screenheight = 864;
open DISPLAY, "/usr/bin/X11/xwininfo -root -display :0.0 |" or die "Can't get root window info.\n";
while (<DISPLAY>) {
    chop;
    if (/Width:\s*(\d.+)/) { $screenwidth = $1;}
    elsif (/Height:\s*(\d.+)/) { $screenheight = $1;}
}

#  Get a directory list (ls short form) of the backgrounds dir

my $bgdir = $ENV{BACKGROUNDS};
my $bgdir = "/home/stan/images";
if ($bgdir eq "") {
    $bgdir = "/home/stan/images";
}
my @imagelist = `ls $bgdir`;


#  Randomly select one

my $myimage = $imagelist[rand(scalar(@imagelist))];
open BGNAME, ">$ENV{HOME}/.bgname" or warn "Couldn't open name file\n";
print BGNAME "$myimage";
close BGNAME;
chop($myimage);

#  Identify it and break out the dimensions. Quote the name to allow
#  for some special characters in the names

my ($iname, $itype, $idim, $etc) = split(/\s/, `/usr/bin/identify $bgdir/"$myimage"`);
my ($iwidth, $iheight) = split("x", $idim);

#  Generate a set of cropping specifications (geometry)

my $screenaspect = $screenheight/$screenwidth;
my $imaspect = $iheight/$iwidth;
my ($newwidth, $newheight);
$newwidth = $iwidth;
$newheight =  $iheight;

if ($imaspect < $screenaspect) { #  Crop from right
   $newwidth = $iheight/$screenaspect;
} else {               # Crop from bottom
  $newheight = $iwidth*$screenaspect;
}

#  Try with both xv and ImageMagick -- use ImageMagick
#  Switched to use xv Thu Jan 28 17:40:54 PST 1999

# my $cmd = "/usr/X11R6/bin/xv -display :0.0 -root -maxpect -quit -crop 0 0 $newwidth $newheight $bgdir/$myimage";
my $cmd = "/usr/bin/xv -display :0.0 -root -maxpect -quit -rm 5 $bgdir/$myimage";
my $cropspec = int($newwidth) . "x" . int($newheight);

my $cmd2 = "display -crop $cropspec -geometry $screenwidth" . "x" . 
    "$screenheight -window root $bgdir/$myimage";

system($cmd);


Thanks for the help!

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
						-- Benjamin Franklin



Reply to: