approach for sudo to have X windows working
[feisty_meow.git] / scripts / core / launch_feisty_meow.sh
index eaa9e7e2ba280ea5a677363d445058cc847fe282..4a6184e687571f4a8c8404eaa09dd0e334eaa2b1 100644 (file)
@@ -19,7 +19,7 @@
 ##############
 
 # this script cannot handle figuring out where it lives, so approaches that
-# get the WORKDIR will fail.  this is a consequence of this always being used
+# get the THISDIR will fail.  this is a consequence of this always being used
 # in bash's 'source' directive, which does not pass the script name as
 # argument 0.  instead, we just check for the bad condition of a malconfigured
 # script system and try to repair it.
@@ -46,7 +46,8 @@ directory where it is stored, e.g.:
 
   cd /opt/feistymeow.org/feisty_meow
 
-and run this command (the whole unwieldy thing on multiple lines):
+and run this command (the whole unwieldy multiple line chunk inside the bars):
+
 
 ##############
   exec bash -i 3<<EOF 4<&0 <&3
@@ -58,14 +59,15 @@ and run this command (the whole unwieldy thing on multiple lines):
 EOF
 ##############
 
-Note that this assumes that the .bashrc file could still need editing to fix
-an erroneous FEISTY_MEOW_APEX variable, so we skip it above when bash runs.
-Check \$HOME/.bashrc to see if a change there will fix the problem.
+
+This code snippet assumes that the .bashrc file could still need editing to
+fix an erroneous FEISTY_MEOW_APEX variable, so we skip it above when bash
+runs.  Check \$HOME/.bashrc to see if a change there will fix the problem.
 
 "
 else
   # apex is good, so let's make the scripts good too.
-  if [ ! -d "$FEISTY_MEOW_SCRIPTS" ]; then
+  if [ -z "$FEISTY_MEOW_SCRIPTS" -o ! -d "$FEISTY_MEOW_SCRIPTS" ]; then
     export FEISTY_MEOW_SCRIPTS="$FEISTY_MEOW_APEX/scripts"
   fi
   # check again to test our belief system...
@@ -75,11 +77,6 @@ else
   fi
 fi
 
-#; /bin/bash -i --norc --noprofile\" > \$HOME/fm-fix 
-#; exec /bin/bash -i --norc --noprofile -c 'bash \$HOME/fm-fix ; echo hello ; read line'
-#--norc --noprofile 
-#; source \$FEISTY_MEOW_APEX/scripts/core/launch_feisty_meow.sh
-
 if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
 
   # we believe it's safe to run through the rest of this script.
@@ -95,6 +92,13 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
   if [ -z "$USER" -a ! -z "$CRONUSER" ]; then
     export USER="$CRONUSER"
   fi
+
+  # use the xauth info if we were given one in the environment.
+  # this allows root or other su'd identities to create windows with same
+  # display variable.
+  if [ ! -z "$DISPLAY" -a ! -z "$IMPORTED_XAUTH" ]; then
+    xauth add "$IMPORTED_XAUTH"
+  fi
   
   ##############
   
@@ -125,9 +129,8 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
     fi
   
     ##############
-  
+
     if [ -z "$ERROR_OCCURRED" ]; then
-  
       # pull in our generated variables that are the minimal set we need to find
       # the rest of our resources.
       source "$FEISTY_MEOW_VARIABLES_LOADING_FILE"
@@ -141,10 +144,9 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
   ##############
 
   if [ -z "$ERROR_OCCURRED" ]; then
-
-    # load the larger body of standard feisty meow variables into the environment.
-    # we actually want this to always run also; it will decide what variables need
-    # to be set again.
+    # no error occurred in our tests above, so load the larger body of standard feisty
+    # meow variables into the environment.  we actually want this to always run also;
+    # it will decide what variables need to be set again.
     source "$FEISTY_MEOW_SCRIPTS/core/variables.sh"
 
     ##############
@@ -159,6 +161,7 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
 
     ##############
 
+#hmmm: abstract this to a twiddle shell options method.
     # check hash table before searching path.
     shopt -s checkhash
     # don't check path for sourced files.
@@ -219,5 +222,25 @@ if [ "$NO_REPAIRS_NEEDED" == "true" ]; then
     unset FEISTY_MEOW_SHOW_LAUNCH_GREETING
   fi
 
+  # only run this hello file if the core feisty meow support haven't been loaded already.  this
+  # hopefully guarantees we show the info at most once in one shell continuum.
+  # this can also be disabled if the NO_HELLO variable has a non-empty value.
+  type CORE_VARIABLES_LOADED &>/dev/null
+  if [ $? -ne 0 -a -z "$NO_HELLO" ]; then
+    # print out a personalized hello file if we find one.
+    if [ -f ~/hello.txt ]; then
+      echo
+      sep 28
+      perl $FEISTY_MEOW_SCRIPTS/*/filedump.pl ~/hello.txt
+      sep 28
+      echo
+    fi
+    # from now on there should be no extra helloing.
+    export NO_HELLO=true
+  fi
+
+  # load the last bits we do here.
+  source "$FEISTY_MEOW_LOADING_DOCK/fmc_ending_sentinel.sh"
+
 fi # "$NO_REPAIRS_NEEDED" was == "true"