1 --- wmjmail.c Tue Nov 30 07:36:05 1999
2 +++ wmjmail.new Wed Mar 28 07:40:06 2001
12 +#include <sys/stat.h>
13 +#include <sys/time.h>
14 +#include <sys/types.h>
16 +#define SPOOLDIR "/var/spool/mail/"
17 +#define APPLICATION "xterm -sb -sl 2000 +si +sk -title XTerm -fg black -bg wheat -geometry 71x50-0-0 -e mutt &"
20 +static char my_folder[256];
21 +static char my_app[256];
22 +static int my_new, my_tot, my_read;
26 printf("-s <sec>: Seconds between executions of mailchk\n");
28 void setup(int argc, char** argv) {
31 - while( -1 != (c = getopt(argc, argv, "hrs:"))) {
33 + snprintf (my_app, 255, "%s", APPLICATION);
34 + snprintf (my_folder, 255, "%s/%s", SPOOLDIR, getenv("USER"));
36 + while( -1 != (c = getopt(argc, argv, "hrs:x:f:"))) {
39 case 'h': show_help();
41 case 'r': dontread = 1; break;
42 case 's': i=atoi(optarg); break;
43 + case 'x': snprintf (my_app, 255, "%s", optarg); break;
44 + case 'f': snprintf (my_folder, 255, "%s", optarg); break;
48 set_update_delay((i) ? i : 15); /* seconds */
49 set_loop_delay(1000); /* mu seconds */
53 - int i, new, tot, read;
55 - FILE *f = popen("mailchk", "r");
56 - fscanf(f, "%i - %i - %i", &new, &tot, &read);
62 + fprintf (stderr, "Stat '%s'\n", my_folder);
63 + if ( stat (my_folder, &buf) != 0 )
66 + fprintf (stderr, "Could not stat '%s'\n", my_folder);
70 + if ( size != buf.st_size )
72 + FILE *f = popen ("mailchk", "r");
73 + fscanf (f, "%i - %i - %i", &my_new, &my_tot, &my_read);
81 jpprintf(0, 0, YELLOW, " J-mail");
83 - jpprintf(1, 2, BLUE, "New", new);
84 - jprintf(GREEN, ":");
86 - jpprintf(7, 2, RED, "%i", new);
87 + jpprintf(1, 2, BLUE, "New");
88 + jpprintf(6, 2, GREEN, ":");
90 + jpprintf(7, 2, RED, "%i", my_new);
92 - jpprintf(7, 2, CYAN, "%i", new);
93 + jpprintf(7, 2, CYAN, "%i", my_new);
97 - jpprintf(1, 3, BLUE, "Read", read);
98 - jprintf(GREEN, ":");
99 - jpprintf(7, 3, CYAN, "%i", read);
101 + jpprintf(1, 3, BLUE, "Read");
102 + jpprintf(6, 3, GREEN, ":");
103 + jpprintf(7, 3, CYAN, "%i", my_read);
106 - jpprintf(1, 4, BLUE, "Total", tot);
107 - jprintf(GREEN, ":");
108 - jpprintf(7, 4, CYAN, "%i", tot);
109 + jpprintf(1, 4, BLUE, "Total");
110 + jpprintf(6, 4, GREEN, ":");
111 + jpprintf(7, 4, CYAN, "%i", my_tot);
118 void do_button_release() {