My favorite X Windows program for monitoring mailboxes is xbuffy. You can get
the latest version at
<ftp://tigger.itc.virginia.edu/pub/src/xbuffy3.3.tar.gz>.
Xbuffy can be configured to pop-up temporary windows containing the From: and
Subject: headers whenever incoming e-mail arrives. You can configure it to
play any sound you want when any given mailbox receives new mail. You can
also configure it so that clicking on a mailbox executes some program (like
your mail program). It's very cool, I think.
Or, you can do it in tk.
John
--
John Conover, 631 Lamont Ct., Campbell, CA., 95008, USA.
VOX 408.370.2688, FAX 408.379.9602
john(_at_)johncon(_dot_)com
#!/usr/local/bin/wish -f
#
# tkbiff, multi-file biff with tk/tcl interface buttons to invoke the
# MUA on each file
#
# A license is hereby granted to reproduce this software source code and
# to create executable versions from this source code for personal,
# non-commercial use. The copyright notice included with the software
# must be maintained in all copies produced.
#
# THIS PROGRAM IS PROVIDED "AS IS". THE AUTHOR PROVIDES NO WARRANTIES
# WHATSOEVER, EXPRESSED OR IMPLIED, INCLUDING WARRANTIES OF
# MERCHANTABILITY, TITLE, OR FITNESS FOR ANY PARTICULAR PURPOSE. THE
# AUTHOR DOES NOT WARRANT THAT USE OF THIS PROGRAM DOES NOT INFRINGE THE
# INTELLECTUAL PROPERTY RIGHTS OF ANY THIRD PARTY IN ANY COUNTRY.
#
# Copyright (c) 1995, John Conover, All Rights Reserved.
#
# Comments and/or bug reports should be addressed to:
#
# john(_at_)johncon(_dot_)com (John Conover)
#
# possible configuration for GNU emacs rmail:
#
# ${HOME}/.Mail, primary unix mail box-procmail could put incoming
# mail into folders in this directory
#
# ${HOME}/.Rmail, secondary mail box, where emacs places mail that
# is being read, or is going to be read; editing any file in this
# directory that is a babyl file header will place emacs in rmail
# mode
#
# set maillist, below, to ".Rmail" since emacs will have one babyl
# header per mail box in this directory-scandir will scan this
# directory for file names, which will become the names on the
# mail box buttons
#
# possible configuration for GNU emacs Vm:
#
# ${HOME}/.Mail, primary unix mail box-procmail could put incoming
# mail into folders in this directory
#
# ${HOME}/.Vm, secondary mail box, where Vm places mail that is
# being read, or is going to be read; additionally, the
# ${HOME}/.vm file should have a:
#
# (setq vm-spool-files '
# (
# ("~/.Vm/mymail" "~/.Mail/mymail" "~/.Vm/.mymail")
# )
# )
#
# record for each mail box file that can be in the ${HOME}/.Mail
# directory so that editing any file in ${HOME}/.Vm will place
# emacs in vm mode
#
# set maillist, below, to ".Mail" since vm will leave one file
# per mail box in this directory-scandir will scan this directory
# for file names, which will become the names on the mail box
# buttons
#
# user configurable variables:
#
# Bisque frame colors for tk 4.0, comment out if tk 3.6, or for
# standard grey
# tk_bisque
# ${HOME} environment variable:
set home "$env(HOME)"
# unix primary mail box directory is ${HOME}/.Mail:
set mail ".Mail"
# directory that contains one file for each mail box, ${HOME}/.Mail or
# ${HOME}/.Rmail
set maillist ".Mail"
# set maillist ".Rmail"
# secondary mail directory when using vm is in ${HOME}/.Vm or
# ${HOME}/.Rmail when using rmail:
set secondary ".Vm"
# set secondary ".Rmail"
# font used for all text:
set font "-adobe-helvetica-bold-r-*-*-12-*-*-*-*-*-*-*"
# Mail User Agent for editing mail, emacs server/rmail, etc.:
# set mua "$env(EDITOR)"
# set mua "/usr/local/bin/emacs"
set mua "/usr/local/bin/emacsclient"
#
# end of user configurable variables
#
# frame style
#
# frame menu bar is raised 2, runs across top:
frame .mbar -relief raised -bd 2
pack .mbar -side top -fill x
# file pull down menu on frame bar:
menubutton .mbar.file -text File -underline 0 -menu .mbar.file.menu -font $font
pack .mbar.file -side left
# file pull down menu-one button to rescan ${HOME}/.Mail or
# ${HOME}/.Rmail, and a button to quit:
menu .mbar.file.menu
.mbar.file.menu add command -label Scan -command "rescandir arg" -font $font
.mbar.file.menu add command -label Quit -command exit -font $font
tk_menuBar .mbar .mbar.file
focus .mbar
# the variable "a" will contain a list of the base names of all file
# names in the ${HOME}/.Mail or ${HOME}/.Rmail directory, initialize
# it to null:
set a {}
#
# the variable c signifies that a scandir is to be done, 0 no, 1 yes
#
set c 1
#
# the proceedure to invoke the MUA, the emacs server/vm/rmail:
#
proc edit file {
global mua
exec $mua $file
}
#
# the proceedure to scan the ${HOME}/.Mail or ${HOME}/.Rmail directory
# for file names:
#
proc scandir arg {
global a
global maillist
global secondary
global font
global home
#
# if there are already file buttons, destroy them
#
set i [expr [llength $a] -1]
while {$i >= 0} {
set x [lindex $a $i]
destroy .$x
incr i -1
}
#
# scan the ${HOME}/.Mail or ${HOME}/.Rmail directory for file
# names, placing them in a; scan a, placing the basename of the
# files in b
#
set a [glob -nocomplain "$home/$maillist/*"]
if [expr [llength $a] > 0] {
set b {}
set i [expr [llength $a] -1]
while {$i >= 0} {
set x [file tail [lindex $a $i]]
if ![string match *~ $x] {
lappend b $x
}
incr i -1
}
#
# sort the basenames, and make buttons for all files; the button,
# when pressed, will invoke the MUA on the file name in
# ${HOME}/.Mail by editing a file in ${HOME}/.Vm or ${HOME}/.Rmail
#
set a [lsort -ascii -decreasing $b]
set i [expr [llength $a] -1]
while {$i >= 0} {
set x [lindex $a $i]
button .$x -text "$x" -highlightthickness 0 -padx 0 -pady 0 -fg
black -command "edit $home/$secondary/$x" -font $font
pack .$x -anchor nw
incr i -1
}
}
}
#
# the proceedure to scan the ${HOME}/.Mail directory for file names
# that exist and are not zero length, ie., contain mail
#
# there is an issue here: to conserve cpu resources, the files should
# not be continually scanned, but the only "wait" function available in
# tk is "after." While "after" is executing, no events (like responding
# to mouse movement, or button events,) will be processed, which makes
# the display unresponsive. The solution is to do very short "after"s
# while in the file search loop, with a corresponding "update" call-the
# responsiveness of the display is acceptable, and both the "time" and
# "top" commands run over many minutes of operation indicate that the
# cpu resources required are very minimal
#
proc scanfiles arg {
global a
global c
global mail
global home
#
# scan the directory? this is done at the top of the loop to avoid
# concurrency issues since this loop can be running when the
# rescan button is pushed from the file menu, altering $a, which
# could be being processed in this function
#
if {$c == 1} {
scandir arg
set c 0
}
#
# any files in ${HOME}/.Mail or ${HOME}/.Rmail, if not update and
# wait for a tenth of a second for the rescan button to be pressed
#
if [expr [llength $a] > 0] {
#
# yes, their are files; for each file name (or button):
#
set i [expr [llength $a] -1]
while {$i >= 0} {
set x [lindex $a $i]
set y $home/$mail/$x
#
# if the file exists, and is not zero length, configure the
# button red, else configure it black, other options include
# -bg for background of the button, etc.
#
if ![file exists $y] {
.$x config -fg black
} else {
set z [file size $y]
if {$z == 0} {
.$x config -fg black
} else {
.$x config -fg red
}
}
#
# update the display, and wait 100 milliseconds
#
update
after 100
incr i -1
}
} else {
update
after 100
}
}
proc rescandir arg {
global c
set c 1
}
#
# main proceedure: forever scan the ${HOME}/.Mail directory for
# file names that exist and are not zero length, ie., contain mail
#
while {1 > 0} {
scanfiles arg
}