#
# tkt setup local to my group
#
# Dave Clemans, June 1993
#
set tktSunWishCmd "/home/dclemans/bin/sss/wishx"
set tktHPWishCmd "/home/dclemans/bin/hpu/wishx"
set tktApolloWishCmd "/net/wvfs08i2/fs/3/dclemans/bin/m/wishx"
set tktRshCmd "/usr/bin/rsh"
set tktXhostCmd "/usr/bin/X11/xhost"
set tkt_apollolibrary "/net/wvfs08i2/fs/3/dclemans/src/tke"
case $tkutVco in {
   {hpu} {
      set tktRshCmd "/usr/bin/remsh"
   }
   {sss} {
      set tktRshCmd "/usr/ucb/rsh"
      set tktXhostCmd "/usr/openwin/bin/xhost"
   }
   {m} {
      set tktRshCmd "/bsd4.3/usr/ucb/rsh"
   }
}

#
# Make sure the remote system can access our display
#
proc tktUserAllowCalls {name} {
   global tktXhostCmd
   set hosts [exec $tktXhostCmd]
   if {[string first "$name" "$hosts"] < 0} {
      exec $tktXhostCmd $name
   }
}

#
# Set up a window to a Sun
#
proc tktUserCallSun {name} {
   global tktRshCmd
   global tktSunWishCmd
   global tkt_library
   global tktShell
   global tkutLocalSystem
   global env
   tktUserAllowCalls $name
   set cmd "DISPLAY=$env(DISPLAY) $tktSunWishCmd -f $tkt_library/tkterm.tk $tktShell </dev/null >/dev/null 2>/dev/null &"
   catch {exec $tktRshCmd $name /bin/sh << "$cmd" &}
#   if {[fork] == 0} {
#      catch {exec $tktRshCmd $name /bin/sh << "$cmd" > /dev/null}
#      exit 0
#   }
}

#
# Set up a window to a HP
#
proc tktUserCallHP {name} {
   global tktRshCmd
   global tktHPWishCmd
   global tkt_library
   global tktShell
   global tkutLocalSystem
   global env
   tktUserAllowCalls $name
   set cmd "DISPLAY=$env(DISPLAY) $tktHPWishCmd -f $tkt_library/tkterm.tk $tktShell </dev/null >/dev/null 2>/dev/null &"
   catch {exec $tktRshCmd $name /bin/sh << "$cmd" &}
#   if {[fork] == 0} {
#      catch {exec $tktRshCmd $name /bin/sh << "$cmd" > /dev/null}
#      exit 0
#   }
}

#
# Set up a window to an Apollo
#
proc tktUserCallApollo {name} {
   global tktRshCmd
   global tktApolloWishCmd
   global tkt_apollolibrary
   global tktShell
   global tkutLocalSystem
   global env
   tktUserAllowCalls $name
   set cmd "DISPLAY=$env(DISPLAY) $tktApolloWishCmd -f $tkt_apollolibrary/tkterm.tk $tktShell </dev/null >/dev/null 2>/dev/null &"
#  catch {exec $tktRshCmd $name /bsd4.3/bin/sh << "$cmd" > /dev/null}
   if {[fork] == 0} {
      catch {exec $tktRshCmd $name /bsd4.3/bin/sh << "$cmd" > /dev/null}
      exit 0
   }
}

#
# User hook to add things to the tkt menu bar
#
proc tktUserMenuHook {menu} {
   menubutton $menu.remote -text "Servers" -menu $menu.remote.m
   menu $menu.remote.m
   $menu.remote.m add command -label "artic" -accelerator "- HP" \
      -command "tktUserCallHP artic"
   $menu.remote.m add command -label "firebird" -accelerator "- HP" \
      -command "tktUserCallHP firebird"
   $menu.remote.m add command -label "stimpy" -accelerator "- HP" \
      -command "tktUserCallHP stimpy"
   $menu.remote.m add command -label "tripe" -accelerator "- HP" \
      -command "tktUserCallHP tripe"
   $menu.remote.m add separator
   $menu.remote.m add command -label "atlantic" -accelerator "- Sun" \
      -command "tktUserCallSun atlantic"
   $menu.remote.m add command -label "lotus" -accelerator "- Sun" \
      -command "tktUserCallSun lotus"
   $menu.remote.m add command -label "ren" -accelerator "- Sun" \
      -command "tktUserCallSun ren"
   $menu.remote.m add command -label "tofu" -accelerator "- Sun" \
      -command "tktUserCallSun tofu"
   $menu.remote.m add separator
   $menu.remote.m add command -label "build_201" -accelerator "- Apollo" \
      -command "tktUserCallApollo build_201"
   $menu.remote.m add command -label "build_202" -accelerator "- Apollo" \
      -command "tktUserCallApollo build_202"
   $menu.remote.m add command -label "build_203" -accelerator "- Apollo" \
      -command "tktUserCallApollo build_203"
   $menu.remote.m add command -label "build_204" -accelerator "- Apollo" \
      -command "tktUserCallApollo build_204"
   $menu.remote.m add command -label "build_205" -accelerator "- Apollo" \
      -command "tktUserCallApollo build_205"
   $menu.remote.m add command -label "build_206" -accelerator "- Apollo" \
      -command "tktUserCallApollo build_206"

   menubutton $menu.group -text "Group" -menu $menu.group.m
   menu $menu.group.m
   $menu.group.m add command -label "cycle" -accelerator "- HP" \
      -command "tktUserCallHP cycle"
   $menu.group.m add command -label "grunge" -accelerator "- HP" \
      -command "tktUserCallHP grunge"
   $menu.group.m add command -label "sheep" -accelerator "- HP" \
      -command "tktUserCallHP sheep"
   $menu.group.m add command -label "slider" -accelerator "- HP" \
      -command "tktUserCallHP slider"
   $menu.group.m add separator
   $menu.group.m add command -label "bigbird" -accelerator "- Sun" \
      -command "tktUserCallSun bigbird"
   $menu.group.m add command -label "chevelle" -accelerator "- Sun" \
      -command "tktUserCallSun chevelle"
   $menu.group.m add command -label "elvis" -accelerator "- Sun" \
      -command "tktUserCallSun elvis"
   $menu.group.m add command -label "hoops" -accelerator "- Sun" \
      -command "tktUserCallSun hoops"
   $menu.group.m add command -label "sherlock" -accelerator "- Sun" \
      -command "tktUserCallSun sherlock"
   $menu.group.m add separator
   $menu.group.m add command -label "glennr"  -accelerator "- Apollo" \
      -command "tktUserCallApollo glennr"
   $menu.group.m add command -label "louisas" -accelerator "- Apollo" \
      -command "tktUserCallApollo louisas"

   pack append $menu $menu.remote right
   pack append $menu $menu.group right
}
