#!/usr/bin/perl -w
use strict;
my @defaultres=(800,600);
my $normw=1024;
my $normh=768;

my $xeyes='/usr/bin/xeyes';


sub getres {
  my @res=(0,0);
  open(W,"xwininfo -root|") or return(@defaultres); 
  while(<W>) {
    chomp;
    if (/Width: (\d+)/) {
      $res[0]=$1;
    } elsif (/Height: (\d+)/) {
      $res[1]=$1;
    }
  }
  close(W);
  return @res;
}

(my $wd,my $hg)=getres();
print "width=$wd\nheight=$hg\n";

my $sy = 1.0 * $hg/$normh;
my $sx = 1.0 * $wd/$normw;

print "sx=$sx\nsy=$sy\n";

my $w=int(0.5 + 66 * $sx);
my $h=int(0.5 + 34 * $sy);
my $xpos=int(0.5 + 84 * $sx );
my $ypos=int(0.5 + 64 * $sy );

my $geo=$w . 'x' . join('+',$h,$xpos,$ypos);
print "executing: ",join(' ',$xeyes,'-geometry',$geo),"\n";
exec($xeyes,'-geometry',$geo,'-outline','white');


