#!/usr/bin/env perl # xboard.wrapper - Low-level wrapper for "xboard" # Revision: 111217 #--------------------------------------------------------------------- # module setup #--------------------------------------------------------------------- require 5.8.1; use strict; use Carp; use warnings; # Trap warnings $SIG {__WARN__} = sub { die @_; }; #--------------------------------------------------------------------- # basic constants #--------------------------------------------------------------------- use constant ZERO => 0; # Zero use constant ONE => 1; # One use constant FALSE => 0; # Boolean FALSE use constant TRUE => 1; # Boolean TRUE #--------------------------------------------------------------------- # program parameters #--------------------------------------------------------------------- my $PREFIX = "__META_PREFIX__"; my $BINDIR = "$PREFIX/bin"; my $EXEPATH = "$BINDIR/xboard.bin"; #--------------------------------------------------------------------- # main routine #--------------------------------------------------------------------- sub Main { my $n; # Scratch (integer ) my $str; # Scratch (string ) my $has_size = FALSE; for (@ARGV) { next unless $_ =~ m@^-(boardsize|size)\b@i; $has_size = TRUE; last; } if (!$has_size) { $str = `getx11dim 2>&1`; $str = "" unless defined $str; my ($w, $h) = $str =~ m@^(\d+)x(\d+)\b@; $w = 1024 unless defined $w; $h = 768 unless defined $h; $str = 'Bulky'; $str = 'Moderate' if $h < 800; $str = 'Average' if $w < 1280; unshift (@ARGV, '-size', $str); } unshift (@ARGV, 'false'); unshift (@ARGV, '-highlightLastMove'); chdir ('/tmp'); exec $EXEPATH, @ARGV; } #--------------------------------------------------------------------- # main program #--------------------------------------------------------------------- &Main(); # Call the main routine exit ONE; # Should't be reached