#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create:
#	README
#	tkpostage
#	Postage.xbm
# This archive created: Fri Oct  1 09:56:08 1993
# By:	Dan Wallach ()
export PATH; PATH=/bin:/usr/bin:$PATH
echo shar: "extracting 'README'" '(1975 characters)'
if test -f 'README'
then
	echo shar: "will not over-write existing file 'README'"
else
sed 's/^X//' << \SHAR_EOF > 'README'
Xtkpostage, Copyright 1993 by Dan Wallach <dwallach@cs.princeton.edu>
X    inspired by xpostage, by Cliff Herod, Convex Computer Corp, 1989.
X    128x64 bitmap image used with permission.
X
Xtkpostage is an xbiff-replacement which tells you how many messages
Xare waiting, and allows you to "quickly" scan the headers -- just click
Xon the window!
X
XTo install this package, you may want to customize some of the things
Xlisted near the string "CONFIGURE".
X
XIn particular, you'll be putting the file Postage.xbm somewhere that
Xtkpostage can find it, and you'll be editing one line of the file to
Xsay where that is.
X
XNOTE: TkPostage requires Tk3.3 and Tcl7.0 (and was developed against
Xthe beta-3 releases)
X
XAlso, if you like to have over 1000 messages in your mail spool, things
Xmay start looking ugly on the user interface.
X
XFor those who like to compare and contrast Tcl/Tk with Xt programming,
Xtkpostage consumes 211 lines of Tcl.  xpostage, which does essentially
Xthe same thing, containes 915 lines of C, including 89 lines which is
Xreally just the X bitmap.  So, the Tcl/Tk version is effectively 1/4
Xthe code, while doing all the same things.
X
XFor those who like playing with X resources, you can specify resources
Xfor Tk in the same way you would for an Xt application, and tkpostage
Xalso recognizes:
X
X    tkpostage.foreground: color-spec
X    tkpostage.background: color-spec
X
Xas colors to use for the postage meter display.  The "headers" display
Xwill still use the default Tk color scheme.
X
Xtkpostage makes a valiant attempt to figure out where your e-mail goes
Xwhen it arrives, checking /usr/spool/mail/$USER and /usr/mail/$USER.
XIf the environment variable MAILDROP is set, that overrides these checks.
XIf the X resource:
X
X    tkpostage.mailDrop: file-name
X
Xis set, this takes the most precedence.
X
XIf you like to keep a large mail spool, you'll probably find this scanning
Xfeature pretty slow.  Would people object to an external Perl program to
Xgenerate the same text?
X
SHAR_EOF
if test 1975 -ne "`wc -c < 'README'`"
then
	echo shar: "error transmitting 'README'" '(should have been 1975 characters)'
fi
fi
echo shar: "extracting 'tkpostage'" '(5560 characters)'
if test -f 'tkpostage'
then
	echo shar: "will not over-write existing file 'tkpostage'"
else
sed 's/^X//' << \SHAR_EOF > 'tkpostage'
X#!/usr/local/bin/wish -f
X
X#
X# tkpostage, Copyright 1993 by Dan Wallach <dwallach@cs.princeton.edu>
X#
X# To install this package, you may want to customize some of the things
X# listed near the string "CONFIGURE".  See the README file for details.
X#
X# $Id: tkpostage,v 1.9 93/10/01 09:51:49 dwallach Exp Locker: dwallach $
X#
X
X##############################################################################
X# CONFIGURE: you have to tweak "bitmap", and you may need to tweak the fonts
X# and/or delay to fit better into your environment
X##############################################################################
X
Xset bitmap "@/u/dwallach/lib/xbm/Postage.xbm";
X
Xset user $env(USER);	# this *should* work...
X
Xset numberFont "-adobe-helvetica-*-r-*-*-20-*-*-*-*-*-*-*";
Xset detailFont "6x13";  # when presenting the list of headers...
X
Xset delay 2000;		# check mail every 2 seconds (== 2000 msec)
X
X##############################################################################
X# that should be it for configurable stuff
X##############################################################################
X
Xif {$tk_version<3.3} {
X    puts stdout "tkpostage requires Tk version 3.3 or greater.";
X    exit 1;
X}
X
Xset optionMailDrop [option get . mailDrop MailDrop];
X
Xif [string length $optionMailDrop] {
X    set mailDrop $optionMailDrop;
X} elseif [info exists env(MAILDROP)] {
X    set mailDrop $env(MAILDROP);
X} elseif [file isdirectory /usr/spool/mail] {
X    set mailDrop "/usr/spool/mail/$user";
X} elseif [file isdirectory /usr/mail] {
X    set mailDrop "/usr/mail/$user";
X} else {
X    puts stdout "I have no idea where your MAILDROP is.  Sorry.";
X    exit 1;
X}
X
X#
X# Some color handling -- first, we'll try to figure out some useful defaults.
X# Then, we'll go check the options database for tkpostage.foreground and
X# tkpostage.background.  Other options can be specified in the "normal"
X# Tk manner, I suppose.
X#
Xif [string compare [tk colormodel .] monochrome] {
X    # it's color
X
X    set fgColor bisque1;
X    set bgColor black;
X} else {
X    # it's b&w
X
X    set fgColor white;
X    set bgColor black;
X}
X
Xset optionFg [option get . foreground Foreground];
Xset optionBg [option get . background Background];
X
Xif [string length $optionFg] {set fgColor $optionFg};
Xif [string length $optionBg] {set bgColor $optionBg};
X
Xwm title . TkPostage;
Xcanvas .c -width 128 -height 64 -background $bgColor;
X.c create bitmap 0 0 -bitmap $bitmap -anchor nw \
X    -foreground $fgColor -background $bgColor;
Xset mailCountItem [.c create text 83 54 -anchor sw -font $numberFont \
X    -text 000 -fill $fgColor];
X
Xbind .c <Button-1> GetMessageHeaders;
X
Xpack .c;
X
Xproc CountMessages {} {
X    global mailDrop;
X    global mailCountItem;
X
X    set mailHandle [open $mailDrop r];
X    set numMessages 0;
X
X    while {[gets $mailHandle mailText] != -1} {
X	if [regexp "^From " $mailText] {
X	    incr numMessages;
X	}
X    }
X
X    close $mailHandle;
X
X    .c itemconfigure $mailCountItem -text [format "%03d" $numMessages];
X}
X
Xproc GetMessageHeaders {} {
X    global mailDrop;
X    global mailCountItem;
X    global detailFont;
X
X    if {! [file exists $mailDrop]} return;
X
X    #
X    # nuke the window if it's already there, and do nothing else
X    # (after watching people click on the window multiple times
X    # trying to make it go away :-)
X    #
X    if [winfo exists .details] {
X	destroy .details;
X	return;
X    }
X
X    set mailHandle [open $mailDrop r];
X    set numMessages 0;
X    set foundEof 0;
X
X    set headerList {};
X
X    while {[gets $mailHandle mailText] != -1 && !$foundEof} {
X	if [regexp "^From " $mailText] {
X	    incr numMessages;
X
X	    #
X	    # start of a message
X	    #
X
X	    set fromLine {};
X	    set dateLine {};
X	    set toLine {};
X	    set subjectLine {};
X
X	    for {} {!$foundEof} {set foundEof [expr "[gets $mailHandle mailText]==-1"]} {
X		if [regexp "^$" $mailText] break;
X
X		if [regexp "^From:" $mailText] { set fromLine $mailText; }
X		if [regexp "^To:"   $mailText] { set toLine $mailText; }
X		if [regexp "^Subject:" $mailText] { set subjectLine $mailText; }
X		if [regexp "^Date:" $mailText] { set dateLine $mailText; }
X	    }
X
X	    lappend headerList [list $dateLine $toLine $fromLine $subjectLine];
X	}
X    }
X
X    close $mailHandle;
X
X    if {! $numMessages} return;
X
X    toplevel .details;
X    wm title .details "TkPostage -- Headers";
X    text .details.text -wrap none -width 80 -height 24 -font $detailFont \
X	-yscrollcommand ".details.s set";
X    scrollbar .details.s -command ".details.text yview";
X    button .details.close -text "Dismiss" -command {destroy .details};
X
X    pack .details.close -side bottom -fill x;
X    pack .details.s -side right -fill y;
X    pack .details.text -expand yes -fill both;
X
X    set numInserts 0;
X    foreach message $headerList {
X	if {$numInserts != 0} {
X	    .details.text insert 0.0 "------\n";
X	}
X	incr numInserts;
X
X	.details.text insert 0.0 [format "%s\n%s\n%s\n%s\n" \
X	    [lindex $message 0] \
X	    [lindex $message 1] \
X	    [lindex $message 2] \
X	    [lindex $message 3]];
X    }
X
X    .details.text configure -state disabled;
X}
X
Xset spoolOldMTime 0;
Xset spoolMTime 0;
X
Xproc CheckMessages {} {
X    global spoolMTime;
X    global spoolOldMTime;
X    global mailDrop;
X    global delay;
X
X    if {! [file exists $mailDrop]} {
X	after $delay CheckMessages;
X	return;
X    }
X
X    set spoolOldMTime $spoolMTime;
X    set spoolMTime [file mtime $mailDrop];
X
X    if {$spoolMTime != $spoolOldMTime} {
X	#
X	# hey!  it changed!
X	#
X
X	CountMessages;
X    }
X
X    #
X    # set up the infinite loop to keep checking
X    #
X    after $delay CheckMessages;
X}
X
XCheckMessages;
SHAR_EOF
if test 5560 -ne "`wc -c < 'tkpostage'`"
then
	echo shar: "error transmitting 'tkpostage'" '(should have been 5560 characters)'
fi
chmod +x 'tkpostage'
fi
echo shar: "extracting 'Postage.xbm'" '(6486 characters)'
if test -f 'Postage.xbm'
then
	echo shar: "will not over-write existing file 'Postage.xbm'"
else
sed 's/^X//' << \SHAR_EOF > 'Postage.xbm'
X#define Postage_width 128
X#define Postage_height 64
Xstatic char Postage_bits[] = {
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xf8, 0xff, 0xff, 0xff,
X   0xff, 0xff, 0x07, 0xe0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x07,
X   0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x90, 0x07, 0x00, 0x00, 0x04,
X   0x00, 0x00, 0x00, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x50,
X   0x38, 0xfe, 0x03, 0x02, 0x00, 0x00, 0x00, 0x64, 0xf0, 0xff, 0xff, 0xff,
X   0xff, 0x7d, 0x17, 0x30, 0xc6, 0x00, 0xfe, 0xff, 0xff, 0xff, 0xff, 0x03,
X   0x08, 0x00, 0x00, 0x00, 0x00, 0x04, 0x16, 0x10, 0x04, 0x03, 0x40, 0x00,
X   0x00, 0x00, 0x00, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x12, 0x08,
X   0x00, 0xe4, 0x21, 0x00, 0x00, 0x00, 0x00, 0x62, 0xe0, 0xff, 0xff, 0xff,
X   0xff, 0x91, 0x11, 0x08, 0x80, 0x0f, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
X   0x10, 0x00, 0xe0, 0xff, 0x30, 0x33, 0x08, 0x08, 0x70, 0x08, 0x04, 0x00,
X   0x00, 0x00, 0x00, 0x02, 0x20, 0x00, 0x1c, 0x00, 0x87, 0x6c, 0x04, 0x04,
X   0x08, 0x37, 0x02, 0x00, 0x00, 0x00, 0x00, 0x61, 0xc0, 0xff, 0x03, 0x00,
X   0x38, 0x0b, 0x02, 0x04, 0x04, 0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00,
X   0x20, 0x40, 0x5c, 0x49, 0x41, 0x62, 0x01, 0x04, 0x02, 0x40, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x01, 0x40, 0x30, 0xc4, 0x55, 0x81, 0x89, 0x00, 0x02,
X   0xfa, 0x23, 0x00, 0x00, 0x00, 0x00, 0x80, 0x60, 0x80, 0x0f, 0x4c, 0x5d,
X   0x01, 0xa2, 0x00, 0x76, 0x02, 0xfc, 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00,
X   0x00, 0x06, 0x44, 0x55, 0x01, 0xac, 0x00, 0xaa, 0x05, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x5c, 0x55, 0x07, 0x10, 0x01, 0x85,
X   0xc6, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0x80, 0x00, 0x00, 0x00,
X   0x00, 0x60, 0xfe, 0x01, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x80, 0x00, 0x00, 0x00, 0x00, 0x20, 0x01, 0x2c, 0x49, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x90, 0x04,
X   0x48, 0x12, 0x86, 0x63, 0xcc, 0x33, 0xe6, 0x69, 0x20, 0x00, 0x00, 0x00,
X   0x00, 0x80, 0x4d, 0x62, 0x49, 0x12, 0x89, 0x94, 0x92, 0x48, 0x29, 0x08,
X   0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0xfe, 0x85, 0x68, 0x12, 0x81, 0x94,
X   0x82, 0x48, 0x21, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb5, 0x10,
X   0x68, 0x12, 0x86, 0x93, 0x8c, 0x78, 0xed, 0x68, 0x08, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0xbe, 0x41, 0x6d, 0x12, 0x88, 0x90, 0x90, 0x48, 0x29, 0x08,
X   0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x04, 0x6d, 0x12, 0x89, 0x90,
X   0x92, 0x48, 0x29, 0x08, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1a, 0x10,
X   0x64, 0x4d, 0xa6, 0x60, 0x8c, 0x48, 0xe6, 0x69, 0x04, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x44, 0x85, 0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x54, 0x40, 0x67, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x24, 0xe2,
X   0x77, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x02, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x48, 0x98, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x88, 0xd6, 0x7a, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0xcc,
X   0x72, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x02, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0xe8, 0xa7, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xb8, 0x4c, 0x4d, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0xa3,
X   0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x02, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x28, 0xb4, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x58, 0x40, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x28,
X   0x40, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x68, 0x02, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x08, 0x38, 0x40, 0x32, 0x01, 0x00, 0x00, 0x00, 0x32, 0x09,
X   0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x28, 0x40, 0xc0, 0x00, 0x00,
X   0x00, 0x00, 0xc0, 0x08, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x28,
X   0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x04, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x0c, 0x24, 0x40, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x08,
X   0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x44, 0x40, 0x32, 0x01, 0x00,
X   0x00, 0x00, 0x32, 0x09, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x46,
X   0x40, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x68, 0x08, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x0a, 0x46, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x45, 0x40, 0x0c, 0x00, 0x00,
X   0x00, 0x00, 0x0c, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x19, 0x49,
X   0x40, 0x32, 0x01, 0x00, 0x00, 0x00, 0x32, 0x69, 0x20, 0x00, 0x00, 0x00,
X   0x00, 0x80, 0x90, 0x88, 0x40, 0xc0, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x08,
X   0x20, 0x00, 0x00, 0x00, 0x00, 0x80, 0x90, 0x90, 0x40, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x40, 0x00, 0x00, 0x00, 0x00, 0x40, 0x50, 0xa0,
X   0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x80, 0x00, 0x00, 0x00,
X   0x00, 0x20, 0x50, 0x20, 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x80, 0x00, 0x00, 0x00, 0x00, 0x20, 0x50, 0x40, 0x41, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x00, 0x01, 0x24, 0xc4, 0x0c, 0x10, 0xd8, 0x73,
X   0x4f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x06, 0x2a, 0x2a,
X   0x02, 0x0c, 0xfc, 0xff, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x00, 0x08, 0x22, 0x4e, 0x04, 0x02, 0x7e, 0xec, 0x71, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x00, 0x30, 0x2a, 0x8a, 0x88, 0x01, 0xc3, 0x18,
X   0x63, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x40, 0xe4, 0x6a,
X   0x46, 0x80, 0x81, 0x19, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x00, 0x80, 0x03, 0x00, 0x38, 0x00, 0xc3, 0x0c, 0x73, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x1c, 0x00, 0x07, 0x00, 0x00, 0x00,
X   0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0xe0, 0xff,
X   0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0xc0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x6f, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
X   0x00, 0x00, 0x00, 0x00};
SHAR_EOF
if test 6486 -ne "`wc -c < 'Postage.xbm'`"
then
	echo shar: "error transmitting 'Postage.xbm'" '(should have been 6486 characters)'
fi
fi
exit 0
#	End of shell archive
