elwell@tut.cis.ohio-state.edu (Clayton Elwell) (08/11/88)
This little program, while less flashy than some that have come by in this newsgroup, is quite useful. You give it a pair of x and y coordinates, and it puts up an icon showing whether or not you have mail. It could be made smarter, but it works. -----------------------------CUT HERE--------------------------------- #! /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 the files: # psbiff.c # psbiff.cps # This archive created: Wed Aug 10 15:27:43 1988 export PATH; PATH=/bin:$PATH if test -f 'psbiff.c' then echo shar: will not over-write existing file "'psbiff.c'" else cat << \SHAR_EOF > 'psbiff.c' #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <pwd.h> #include <time.h> #include "psbiff.h" char mailbox[80]; struct passwd *pw; struct stat st; main(argc, argv) int argc; char **argv; { long t; int x, y; if (argc < 3) { fprintf(stderr, "usage: psbiff x y"); exit(1); } x = atoi(argv[1]); y = atoi(argv[2]); ps_open_PostScript(); initialize(x, y); ps_flush_PostScript(); pw = getpwuid(getuid()); sprintf(mailbox, "/usr/spool/mail/%s", pw->pw_name); for (;;) { time(&t); sleep(10); if (stat(mailbox, &st)) { nomail(); } else if (t <= st.st_mtime) { newmail(); } else if (st.st_size > 0) oldmail(); else nomail(); ps_flush_PostScript(); } ps_close_PostScript(); } SHAR_EOF fi # end of overwriting check if test -f 'psbiff.cps' then echo shar: will not over-write existing file "'psbiff.cps'" else cat << \SHAR_EOF > 'psbiff.cps' %! cdef initialize(x,y) newprocessgroup /icon framebuffer newcanvas def /xcurs /xcurs_m icon setstandardcursor gsave framebuffer setcanvas 0 0 64 64 rectpath icon reshapecanvas grestore icon /Retained true put icon setcanvas x y movecanvas /destroy { icon /Mapped false put currentprocess killprocessgroup } def /slide { gsave icon setcanvas InteractionLock { interactivemove } monitor grestore } def [ /DoItEvent { gsave /ClientData get cvx exec grestore } /Window null eventmgrinterest AdjustButton { slide } DownTransition icon eventmgrinterest ] forkeventmgr /mailimage 64 64 1 [64 0 0 -64 0 64] { <FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000000003C0000001E0000003 C000000E1C000003C000007003000003C000038000800003C0001C0004400003 C00060001C200003C003F8007C200003C00C0601FC100003C0100101FC100003 C020E081FC080003C041F041FC080003C041F041F8080003C080E021E0040003 C080002180040003C100001100040003C102001100040003C105001100040003 C148C51100040003C272650900040003C265350980040003C242950980040003 C2810D0800040003C30005E800040003C280020800040003C240410800040003 C260A0E800040003C2115048000C0003C27FFFE8003C7003C200000800F08803 C200000803D88803C20000080F270803C20000083C211003C2000008F0113C03 C200000BC00FC203C200000F8031C203C3FFFFFC80412403C3FFFFF880411803 C0004040803F1003C000404080049003C000404080086003C000404080080003 C000404080100003C000404080100003C0004040802DFC03C000404080701403 C000404080C06803C000404081038803C0004040821C1003C000404084202003 C000404088C04003C000404093018003C0004040A4060003C0004040C8180003 C000404080E00003C00040437F000003C000404C00000003C000407000000003 C0007FC000000003C000000000000003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF> } buildimage def /nomailimage 64 64 1 [64 0 0 -64 0 64] { <FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC000000000000003C0000001E0000003 C000000E1C000003C000007003000003C000038000800003C0001C0000400003 C000600000200003C003F80000200003C00C060000100003C010010000100003 C020E08000080003C041F04000080003C041F04000080003C080E02000040003 C080002000040003C100001000640003C100001001E40003C100001007E40003 C14445101BE40003C26CA50863E40003C255150983E40003C255F50983E40003 C245150803E40003C24515E803840003C200000802040003C200000800040003 C27FFFE800040003C2000008000C0003C27FFFE8003C7003C200000800F08803 C200000803D88803C20000080F270803C20000083C211003C2000008F0113C03 C200000BC00FC203C200000F8031C203C3FFFFFC80412403C3FFFFF880411803 C0004040803F1003C000404080049003C000404080086003C000404080080003 C000404080100003C000404080100003C0004040802DFC03C000404080701403 C000404080C06803C000404081038803C0004040821C1003C000404084202003 C000404088C04003C000404093018003C0004040A4060003C0004040C8180003 C000404080E00003C00040437F000003C000404C00000003C000407000000003 C0007FC000000003C000000000000003FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF> } buildimage def gsave textcolor setcolor 64 64 scale false nomailimage imagemaskcanvas backgroundcolor setcolor true nomailimage imagemaskcanvas grestore icon /Mapped true put cdef oldmail() icon setcanvas gsave textcolor setcolor 64 64 scale false mailimage imagemaskcanvas backgroundcolor setcolor true mailimage imagemaskcanvas grestore cdef nomail() icon setcanvas gsave textcolor setcolor 64 64 scale false nomailimage imagemaskcanvas backgroundcolor setcolor true nomailimage imagemaskcanvas grestore cdef newmail() icon setcanvas gsave backgroundcolor setgray 64 64 scale false mailimage imagemaskcanvas textcolor setgray true mailimage imagemaskcanvas grestore SHAR_EOF fi # end of overwriting check # End of shell archive exit 0 Clayton M. Elwell <elwell@tut.cis.ohio-state.edu> Ohio State University CIS Dept. Research Computing Facility "... there was a *third* possibility that we hadn't even counted upon ..." --Arlo Guthrie, "Alice's Restaurant"