#!/usr/bin/perl -wi.bak

use strict;

my $snip_flag;
my $root_col="#5477A0";

while (<>) {
  /xsri/ and $snip_flag=1;

  m/xsetroot.*\"([^\"]+)\"/ and $root_col=$1;

  if ($snip_flag) {
    next unless /^\s*fi\s*$/;
    print <<EOF;
  if [ -x /usr/bin/qiv ]; then
    /usr/bin/qiv --maxpect --random --bg_color \"$root_col\" --root \\\
/etc/X11/xdm/pixmaps/login_pics/* \\\
/afs/fnal.gov/files/code/e898/code/6/login_pics/*
  fi
EOF
    undef $snip_flag;
    next;
  }
  print;
}
