[GRASS-SVN] r30875 - grass/trunk/macosx/app

svn_grass at osgeo.org svn_grass at osgeo.org
Sat Apr 5 23:21:21 EDT 2008


Author: kyngchaos
Date: 2008-04-05 23:21:21 -0400 (Sat, 05 Apr 2008)
New Revision: 30875

Modified:
   grass/trunk/macosx/app/grass.sh.in
Log:
avoid unnecessary focus shift to X11 on startup; return focus to starting term app (if not Terminal.app)

Modified: grass/trunk/macosx/app/grass.sh.in
===================================================================
--- grass/trunk/macosx/app/grass.sh.in	2008-04-06 01:28:04 UTC (rev 30874)
+++ grass/trunk/macosx/app/grass.sh.in	2008-04-06 03:21:21 UTC (rev 30875)
@@ -75,14 +75,31 @@
 fi
 export GRASS_FONT_CAP
 
+# default xterm Terminal emulator
+# note: only app startup defaults this way, CLI build still defaults to xterm
+if [ ! "$GRASS_XTERM" ] ; then
+	GRASS_XTERM="$GISBASE/etc/grass-xterm-mac"
+	export GRASS_XTERM
+fi
+
+# determine current term application (when grass.sh is run directly by the user)
+# use osascript so we can get name of term app, not shell process
+USERTERM=`osascript -e 'tell application "System Events" to item 1 of (get name of processes whose frontmost is true)'`
+if [ ! "$USERTERM" ] ; then
+	USERTERM="Terminal"
+fi
+
 ### X11 stuff
 
-# start X11 if not running - no need to check if running when using 'open'
+# start X11 if not running
 # some users may be annoyed by this, but X11 required for some stuff for now
 if [ -d "/Applications/Utilities/X11.app" ] ; then
 	# no need to start Leopard X11.app
 	if [ ! -d "/usr/X11" ] ; then
-		open /Applications/Utilities/X11.app
+		# check if running anyways, even though not necessary with "open"
+		if [ ! "`ps -axc | grep 'X11$'`" ] ; then
+			open /Applications/Utilities/X11.app
+		fi
 	fi
 fi
 
@@ -98,13 +115,6 @@
 	fi
 fi
 
-# default xterm Terminal emulator
-# note: only app startup defaults this way, CLI build still defaults to xterm
-if [ ! "$GRASS_XTERM" ] ; then
-	GRASS_XTERM="$GISBASE/etc/grass-xterm-mac"
-	export GRASS_XTERM
-fi
-
 # default to internal X11 Tcl/Tk
 @TCLTK_INTERNAL at if [ ! "$GRASS_TCLSH" ] ; then
 	GRASS_TCLSH="$GISBASE/bin/tclsh at TCLTKVER@"
@@ -125,19 +135,22 @@
 	DISPLAY=:0.0
 	export DISPLAY
 fi
+
 ### end X11 block
 
 # if gisrc has text startup, switch back to Terminal (gotta duplicate some init.sh stuff)
 # eventually, when TclTk optional, can run appropriate apps per GUI here (ie X11)
 GISRCRC="$HOME/.grassrc6"
-if [ -f "$GISRCRC" ] ; then
-	GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GISRCRC"`
-fi
 if [ ! "$GRASS_GUI" ] ; then
-	GRASS_GUI="tcltk"
+	if [ -f "$GISRCRC" ] ; then
+		GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GISRCRC"`
+	fi
+	if [ ! "$GRASS_GUI" ] ; then
+		GRASS_GUI="tcltk"
+	fi
 fi
 if [ "$GRASS_GUI" = "text" ] ; then
-	osascript -e 'tell application "Terminal" to activate'
+	osascript -e "tell application \"$USERTERM\" to activate"
 fi
 
 exec "$GISBASE/etc/Init.sh" "$@"



More information about the grass-commit mailing list