Re: Image usage: will Gnome ever do these things?
- From: Jeff Trefftzs <jeff tick tcsn net>
- To: Paul E Johnson <pauljohn ukans edu>
- Cc: "gnome-list gnome org" <gnome-list gnome org>, jeff thoth trefftzs org
- Subject: Re: Image usage: will Gnome ever do these things?
- Date: Wed, 20 Sep 2000 09:36:04 -0700
Paul E Johnson wrote:
> Over the last year, these ideas have come up and at least once
> developers said the first would be possible.
>
> 1. Gnome terminal preferences: Randomly choose a background image from a
> directory.
>
Here's a perl script that I run as a startup program which gives me a random
image from my collection of background pictures.
HTH
--Jeff
------------------------------------ cut here ---------------------------
#!/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 = 900;
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};
if ($bgdir eq "") {
$bgdir = "/home/jeff/images/backgrounds";
}
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, $idim, $etc) = split(/\s/, `/usr/X11R6/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;
my ($xstart, $ystart) = (0, 0);
if ($imaspect < $screenaspect) { # Crop from right
$newwidth = $iheight/$screenaspect;
$xstart = ($iwidth - $newwidth)/2;
} else { # Crop from bottom
$newheight = $iwidth*$screenaspect;
$ystart = ($iheight - $newheight)/2;
}
# 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 $newx $newy $newwidth $newheight $bgdir/$myimage";
my $cropspec = int($newwidth) . "x" . int($newheight). "+" . int($xstart) . "+" . int($ystart);
my $cmd2 = "display -crop $cropspec -geometry $screenwidth" . "x" .
"$screenheight -window root $bgdir/$myimage";
printf STDERR "$cmd2\n";
system($cmd2);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]