#!/.software/local/.admin/bins/bin/wish -f # ============================================================================= # xmail # by Christopher Trudeau, Copyright 1997 # # This tcl/tk script displays a desktop clock which goes inverse video when # new mail arrives. A pull down menu allows the user to launch remote login # sessions on servers specified in the "hosts" variable. The sessions have # the appropriate "xhost" and "DISPLAY" values. # # Comments and criticism on this program are greatly appreciated. Feel free to # send me a note at ctrudeau@etude.uwaterloo.ca. This material is copyright # but non-commercial institutes have permission to reproduce the program in # its entirety, all other uses require explicit written permission of the # author. # ============================================================================= # ---------------------------------------------------------------------------- # Global Settings # ---------------------------------------------------------------------------- # fill in the following list for hosts that you wish to access, spaces or tabs # separating the names of the hosts; eg: # # set hosts "ampere etude watt.uwaterloo.ca" set hosts "ampere watt ohm morse novice" # ---------------------------------------------------------------------------- # Procedures # ---------------------------------------------------------------------------- # proc prRefreshDisplay - called periodically to refresh the displayed time and # status of the mail box proc prRefreshDisplay {} { global last # get the time set i [exec date] set i [ string range $i 11 15 ] # get the mailbox status catch {[exec frm -q -s new]} mail if { [string first "no" $mail] == -1 } { # "You have new mail." results in white on black .lTime configure -fg white -bg black -text $i # if first time set, do the double beep thing if { $last == 0 } { bell after 120 bell } set last 1 } else { # "You have no new mail." results in black on white .lTime configure -fg black -bg white -text $i set last 0 } after 15000 prRefreshDisplay } # ---------------------------------------------------------------------------- # Main Code # ---------------------------------------------------------------------------- # create the main window and place it if specified wm title . "xmail" set args [lindex $argv 0] string trim $args - if { $args == "geometry" } { wm geometry . [lindex $argv 1] } # figure out what terminal name we are at set userName [exec whoami] set termName [exec who ] set temp [string first $userName $termName] set termName [string range $termName $temp end] set temp [string first ( $termName] set temp2 [string first ) $termName] set termName [string range $termName $temp $temp2] set termName [string trim $termName "()"] # initialize variables and widgets set last 0 set font "-*-*-medium-r-normal--*-120-*-*-*-*-*-*" set font2 "-*-*-medium-r-normal--*-100-*-*-*-*-*-*" label .lTime -font $font # create the menu button menubutton .mMenu -relief raised -font $font2 -text ">" -menu .mMenu.m menu .mMenu.m -tearoff 0 .mMenu.m add cascade -label "xterms" -menu .mMenu.m.xterms #create the sub menu "xterms" menu .mMenu.m.xterms -tearoff 0 .mMenu.m.xterms add command -label "local" -command {exec xterm -title local &} set count 0 set hostN [lindex $hosts $count] while { $hostN != "" } { catch { exec xhost $hostN } set cmd "exec rsh $hostN xterm -display $termName:0 -title $hostN &" .mMenu.m.xterms add command -label $hostN -command $cmd incr count 1 set hostN [lindex $hosts $count] } .mMenu.m add separator .mMenu.m add command -label "Exit" -command exit pack .lTime .mMenu -side left prRefreshDisplay # ----------------------------------------------------------------------------