#!/usr/bin/env perl # vchess.wrapper - Launcher for "vchess" main program # License: Creative Commons Attribution-NonCommercial-ShareAlike 2.5 # Revision: 080813 # Note: The license indicated above applies to this file. It doesn't # apply to the official Vulcan Chess package, or to any file derived # from that package. #--------------------------------------------------------------------- # license information #--------------------------------------------------------------------- # This section may not be modified except as approved by the author or # licensor, or to make non-content changes such as adjustments to par- # agraph formatting or white space. # This version of this software is distributed under the following # license: # # Creative Commons Attribution-NonCommercial-ShareAlike 2.5 # You may use, modify, and redistribute this software without fees or # royalties, but only under the terms and conditions set forth by the # license. In particular, copies and derived works cannot be used for # commercial purposes. Additionally, the license propagates to copies # and derived works. Furthermore, you must provide attribution "in the # manner specified by the author or licensor". The latter point is # discussed below. # The author [and licensor] hereby specifies that attribution must be # handled in the following manner: a. If the software is interactive, # any About or Credits dialog boxes, windows, or output text provided # by the original version must be preserved and readily accessible to # the end user at runtime. b. If the software is non-interactive, or # if it does not provide About or Credits dialog boxes, windows, or # output text, the operating system and/or desktop environment used # must provide attribution that is visible and/or readily accessible # to the end user at runtime. # The following techniques do not meet the attribution requirements: # Attribution through text files, attribution through printed docu- # mentation, verbal attribution, or postings on external web sites # [i.e., web sites that are not an intrinsic local component of the # operating system or desktop environment used]. These examples are # provided for illustrative purposes only. # It should be noted that trademarks are an additional issue. If this # software uses any trademarks, trademark-related restrictions may # apply. # This is not a complete explanation of the terms and conditions in- # volved. For more information, see the Creative Commons Attribution- # NonCommercial-ShareAlike 2.5 license. #--------------------------------------------------------------------- # explanation #--------------------------------------------------------------------- # 1. Overview: # This script performs some setup operations and starts the main Vul- # can chess executable [which must be renamed to "vchess.bin"]. Pres- # ently, the following steps are implemented: # # a. It optionally verifies that multiple instances of the program # aren't running. If the test is done, and multiple instances # are running, a fatal-error message is displayed. # # b. It optionally verifies that the program isn't running through # VNC. If the test is done, and the program is running through # VNC, a fatal-error message is displayed. # # c. It optionally verifies that direct rendering is available. # If the test is done, and direct rendering isn't available, a # fatal-error message is displayed. # # d. If optionally checks for NVidia graphics hardware. If the # test is done, and NVidia graphics hardware is present, a # warning message is displayed. Note: The user may exit at this # point. #--------------------------------------------------------------------- # 2. Requirements: # At the GUI level, this program requires Perl 5, "glxinfo", Perl- # Gtk2, and LACSUB. # These components are standard, except for LACSUB. You should be able # to obtain LACSUB from the same place as this file. Note: LACSUB # [like this file] is distributed under a Creative Commons license. # For more information about license issues, see the comments at the # start of this file. #--------------------------------------------------------------------- # standard module setup #--------------------------------------------------------------------- require 5.6.1; use strict; use Carp; use warnings; # Trap warnings $SIG {__WARN__} = sub { die @_; }; #--------------------------------------------------------------------- # add CPAN module[s] #--------------------------------------------------------------------- use Gtk2 '-init'; use Gtk2::SimpleList; #--------------------------------------------------------------------- # add LACSUB module[s] #--------------------------------------------------------------------- use LACSUB::GUI ( @LACSUB::GUI::EXPORT_OK ); #--------------------------------------------------------------------- # 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 $DIR_BASE = '__META_PREFIX__'; my $IE = 'Internal error'; my $PROGNAME = 'vchess'; my $REVISION = '080813'; # Revision [or release] string my $ALERT_ICON_PATH = "$DIR_BASE/misc/alert.png"; my $NEXT_PROGRAM = "$DIR_BASE/bin/$PROGNAME.bin"; #--------------------------------------------------------------------- # If this program requires direct-rendering support, set $FLAG_CHECK_ # DIRECT_RENDERING equal to TRUE. Otherwise, set this flag equal to # FALSE. my $FLAG_CHECK_DIRECT_RENDERING = TRUE; #--------------------------------------------------------------------- # If this program has difficulties with NVidia graphics hardware, set # $FLAG_CHECK_NVIDIA equal to TRUE. Otherwise, set this flag equal to # FALSE. my $FLAG_CHECK_NVIDIA = TRUE; #--------------------------------------------------------------------- # If you'd like to prohibit multiple instances, set $FLAG_PROHIBIT_ # MULTI_INSTANCE to TRUE. Otherwise, set this flag to FALSE. my $FLAG_PROHIBIT_MULTI_INSTANCE = TRUE; #--------------------------------------------------------------------- # If this program shouldn't try to run under VNC, set $FLAG_PROHIBIT_ # VNC equal to TRUE. Otherwise, set this flag equal to FALSE. my $FLAG_PROHIBIT_VNC = TRUE; #--------------------------------------------------------------------- # main routine #--------------------------------------------------------------------- sub Main { #--------------------------------------------------------------------- # Verify that program isn't already running. &VerifyNotRunning ( -icon_path => $ALERT_ICON_PATH , -name => $PROGNAME , -pattern_this => ':\d\d\s(perl |)(\S+/|)' . $PROGNAME . '(|\.wrapper)\s' , -pattern_next => ':\d\d\s(perl |)(\S+/|)' . $PROGNAME . '\.bin\s' ) if $FLAG_PROHIBIT_MULTI_INSTANCE; #--------------------------------------------------------------------- # Go to user's home directory. my $HOME = $ENV {HOME}; $HOME = '/' unless defined $HOME; chdir $HOME; #--------------------------------------------------------------------- # Handle VNC test (if enabled). &AbortIfVNC ( -icon_path => $ALERT_ICON_PATH , -name => $PROGNAME ) if $FLAG_PROHIBIT_VNC; #--------------------------------------------------------------------- # Handle direct-rendering test (if enabled). &AbortUnlessDRI ( -icon_path => $ALERT_ICON_PATH , -name => $PROGNAME ) if $FLAG_CHECK_DIRECT_RENDERING; #--------------------------------------------------------------------- # NVidia-related kludge. &CheckNVidia ( -icon_path => $ALERT_ICON_PATH , -name => $PROGNAME ) if $FLAG_CHECK_NVIDIA; #--------------------------------------------------------------------- # Wrap it up. exec $NEXT_PROGRAM, @ARGV; # Chain to target program } #--------------------------------------------------------------------- # main program #--------------------------------------------------------------------- &Main(); # Call the main routine exit ZERO; # Normal exit