#!/bin/sh # Copyright(c) 1998, Space Science and Engineering Center, UW-Madison # Refer to "McIDAS Software Acquisition and Distribution Policies" # in the file mcidas/data/license.txt # $Id: gui.shk,v 1.27 2020/03/27 18:18:53 davep Exp $ ############################################################################ trap exit INT TERM EXIT # set this to the location of the GUI scripts # GUIDIR=@MCIDAS_GUI_DIRECTORY@ # set this to the builder's McIDAS data directory, # used if user doesn't have a mcidas/data directory # MCDATA=@MCIDAS_DATA_DIRECTORY@ # set this to the location of the McIDAS wish executables # MCWISHDIR=@MCWISH_BIN_DIRECTORY@ # set this to 'yes' if errors should appear in a popup window # MCENV_GUI=yes # set this to the name of the initial GUI script # #SCRIPT=$GUIDIR/gui_toolbar.gui SCRIPT=$GUIDIR/GUIMain.gui ############################################################################ # make sure we can get to McIDAS # if [ -z "$MCENV_POSUC" ]; then echo "\"$0\" must be started from within McIDAS" 1>&2 exit 1 fi # make sure we can get to an X server # if [ -z "$DISPLAY" ]; then echo "No \$DISPLAY environment variable for \"$0\"" 1>&2 exit 1 fi # make sure children get these set properly # export GUIDIR export MCENV_GUI # make sure "our" mcwish is at the front of the path # PATH=$MCWISHDIR:$PATH export PATH ############################################################################ # thumb through PATH, looking for 'mcwish' or 'wish' # OLDIFS="$IFS" IFS=':' set $PATH IFS="$OLDIFS" while [ $# -gt 0 ]; do # if we haven't found a 'mcwish' executable yet... # if [ -z "$MCWISH" ]; then # look for any occurrence of 'mcwish' # for i in $1/mcwish $1/mcwish*; do if [ -f $i -a -z "$MCWISH" ]; then # make sure it's version 4.1 or later # case `echo 'puts $tk_version; exit 0' | $i 2>/dev/null` in 4.[1-9]*) MCWISH=$i;; [56789].[0-9]*) MCWISH=$i;; esac fi done fi # # if we haven't found a 'wish' executable yet... # # # if [ -z "$WISH" ]; then # for i in $1/wish $1/wish*; do # if [ -f $i -a -z "$WISH" ]; then # # # make sure it's version 4.1 or later # # # case `echo 'puts $tk_version; exit 0' | $i 2>/dev/null` in # 4.[1-9]*) WISH=$i;; # [56789].[0-9]*) WISH=$i;; # esac # fi # done # fi shift done ############################################################################ # do our work from the data directory # if [ -d $HOME/mcidas/data ]; then cd $HOME/mcidas/data else cd $MCDATA fi # did we find 'mcwish' or 'wish'? # if [ ! -z "$MCWISH" ]; then PROG=$MCWISH else if [ ! -z "$WISH" ]; then PROG=$WISH fi fi # if we found some sort of wish-like thingie... # if [ ! -z "$PROG" ]; then # set LD_LIBRARY_PATH in case we need to find shared libraries # LIB=`echo $PROG | sed 's/\/bin\//\/lib\//'` if [ -z "$LD_LIBRARY_PATH" ]; then LD_LIBRARY_PATH=$LIB else LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$LIB" fi export LD_LIBRARY_PATH # start up GUI # # Changed 2008-05-21 DJP # Tcl/Tk 8.5.9 not killing the exec'd prog on 'EXIT' from MCTEXT # Change to run in background, read PID then start a watch process to kill it if [ 1 ]; then $PROG -f $SCRIPT 2>/dev/null & PROG_PID=$! # Pin to random single CPU to avoid threading errors PINCMD= NPROC=`nproc 2>/dev/null` TASKSET=`which taskset 2>/dev/null` if [ -n "$NPROC" -a -n "$TASKSET" -a -n "$RANDOM" ]; then CPUPIN=$(($RANDOM%$NPROC)) $TASKSET -cp $CPUPIN $PROG_PID >/dev/null fi # Loop every 5 seconds looking at UC 194. If it changes from "0", exit UNAMES=`uname -s` DO_EXIT="0" while [ "$DO_EXIT" = "0" ]; do if [ "$UNAMES" = "Darwin" ]; then PEEK_EXIT=`ucu.k PEEK 194` DO_EXIT=`echo "$PEEK_EXIT" |awk '{print $6}'` else DO_EXIT=`ucu.k PEEK 194 |awk '{print $6}'` fi sleep 5 done kill $PROG_PID exit 0 else exec $PROG -f $SCRIPT 2>/dev/null fi fi ############################################################################ # whine and die # echo "$0: Couldn't find a 'wish' or 'mcwish' executable in your PATH" 1>&2 exit 1