### Copyright (C) 1995-1997 Jesper K. Pedersen
### This program is free software; you can redistribute it and/or modify
### it under the terms of the GNU General Public License as published by
### the Free Software Foundation; either version 2 of the License, or
### (at your option) any later version.
###
### This program is distributed in the hope that it will be useful,
### but WITHOUT ANY WARRANTY; without even the implied warranty of
### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
### GNU General Public License for more details.
###
### You should have received a copy of the GNU General Public License
### along with this program; if not, write to the Free Software
### Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


proc logout {} {
  # logout

  Desc "Tcsh can log you out, or lock your screen after a specified amount"\
      "of inactivity."
  
  ShortDesc "Configuration of logout"

  ############################### Widgets ##############################
  Int logoutTime \
      -text "Minutes of inactivity before logout" \
      -textafter "(0 - no autologout)" \
      -default 60 

  Int lockTime \
      -text "Minutes of inactivity before lock" \
      -textafter "(0 - no lock)" \
      -default 0 

  Int ignoreeof \
      -text "Number of consecutive Ctrl-D before exit" \
      -textafter "(0 - infinity)" \
      -default 2 

  ################################ Help ################################
  Help logoutTime \
      "This is the number of minutes you have to be inactive in the"\
      "shell before it automatically logs you out."

  Help lockTime \
      "This is the number of minutes you have to be inactive in the"\
      "shell before it automatically locks the shell"

  Help ignoreeof \
      "This option controls how the shell will interpret a Ctrl-D on an"\
      "empty line.\n0 - the shell says: \"use exit to leave\"\n1 -"\
      "leave on the first Ctrl-D\n2 - leave on the second"\
      "Ctrl-D\netc. etc."
  ############################## Page End ##############################
  PageEnd {
    foreach elm {
      {logoutTime "Minutes of inactivity before logout"}
      {lockTime "Minutes of inactivity before lock"}
      {ignoreeof "Number of consecutive Ctrl-D before exit"}} {
      set name [lindex $elm 0]
      set text [lindex $elm 1]
      if {[set $name] == ""} {
        error "Entry with text :\"$text\" is empty"
      }
    }
  }

  ################################ Save ################################
  Save {
    ########## autologout ##########
    if {$logoutTime != 60 || $lockTime || $generateDefault} {
      print "set autologout = ($logoutTime $lockTime)"
    }
    ########## ignoreeof ##########
    if {$ignoreeof != 1 || $generateDefault} {
      print "set ignoreeof = $ignoreeof"
    }
  }
}
