123 lines
3.1 KiB
Diff
123 lines
3.1 KiB
Diff
--- wmjmail.c Tue Nov 30 07:36:05 1999
|
|
+++ wmjmail.new Wed Mar 28 07:40:06 2001
|
|
@@ -3,7 +3,22 @@
|
|
#include <getopt.h>
|
|
#include "jenglish.h"
|
|
|
|
-int dontread = 0;
|
|
+#include <errno.h>
|
|
+#include <fcntl.h>
|
|
+#include <stdio.h>
|
|
+#include <unistd.h>
|
|
+#include <sys/stat.h>
|
|
+#include <sys/time.h>
|
|
+#include <sys/types.h>
|
|
+
|
|
+#define SPOOLDIR "/var/spool/mail/"
|
|
+#define APPLICATION "xterm -sb -sl 2000 +si +sk -title XTerm -fg black -bg wheat -geometry 71x50-0-0 -e mutt &"
|
|
+
|
|
+int dontread = 0;
|
|
+static char my_folder[256];
|
|
+static char my_app[256];
|
|
+static int my_new, my_tot, my_read;
|
|
+static off_t size;
|
|
|
|
void show_help() {
|
|
printf("-s <sec>: Seconds between executions of mailchk\n");
|
|
@@ -15,47 +30,69 @@
|
|
void setup(int argc, char** argv) {
|
|
char c;
|
|
int i;
|
|
- while( -1 != (c = getopt(argc, argv, "hrs:"))) {
|
|
+
|
|
+ snprintf (my_app, 255, "%s", APPLICATION);
|
|
+ snprintf (my_folder, 255, "%s/%s", SPOOLDIR, getenv("USER"));
|
|
+
|
|
+ while( -1 != (c = getopt(argc, argv, "hrs:x:f:"))) {
|
|
switch(c) {
|
|
case '?': exit(1);
|
|
case 'h': show_help();
|
|
|
|
case 'r': dontread = 1; break;
|
|
case 's': i=atoi(optarg); break;
|
|
+ case 'x': snprintf (my_app, 255, "%s", optarg); break;
|
|
+ case 'f': snprintf (my_folder, 255, "%s", optarg); break;
|
|
}
|
|
}
|
|
+
|
|
set_update_delay((i) ? i : 15); /* seconds */
|
|
set_loop_delay(1000); /* mu seconds */
|
|
}
|
|
|
|
void do_update() {
|
|
- int i, new, tot, read;
|
|
-
|
|
- FILE *f = popen("mailchk", "r");
|
|
- fscanf(f, "%i - %i - %i", &new, &tot, &read);
|
|
- pclose(f);
|
|
+ int i;
|
|
+ int in;
|
|
+ struct stat buf;
|
|
+
|
|
+ fprintf (stderr, "Stat '%s'\n", my_folder);
|
|
+ if ( stat (my_folder, &buf) != 0 )
|
|
+ {
|
|
+ perror ("");
|
|
+ fprintf (stderr, "Could not stat '%s'\n", my_folder);
|
|
+ exit (-2);
|
|
+ }
|
|
+
|
|
+ if ( size != buf.st_size )
|
|
+ {
|
|
+ FILE *f = popen ("mailchk", "r");
|
|
+ fscanf (f, "%i - %i - %i", &my_new, &my_tot, &my_read);
|
|
+ pclose (f);
|
|
|
|
+ size = buf.st_size;
|
|
+ }
|
|
+
|
|
clear_window();
|
|
|
|
jpprintf(0, 0, YELLOW, " J-mail");
|
|
|
|
- jpprintf(1, 2, BLUE, "New", new);
|
|
- jprintf(GREEN, ":");
|
|
- if(new) {
|
|
- jpprintf(7, 2, RED, "%i", new);
|
|
+ jpprintf(1, 2, BLUE, "New");
|
|
+ jpprintf(6, 2, GREEN, ":");
|
|
+ if (my_new) {
|
|
+ jpprintf(7, 2, RED, "%i", my_new);
|
|
} else {
|
|
- jpprintf(7, 2, CYAN, "%i", new);
|
|
+ jpprintf(7, 2, CYAN, "%i", my_new);
|
|
}
|
|
|
|
- if(!dontread) {
|
|
- jpprintf(1, 3, BLUE, "Read", read);
|
|
- jprintf(GREEN, ":");
|
|
- jpprintf(7, 3, CYAN, "%i", read);
|
|
+ if (!dontread) {
|
|
+ jpprintf(1, 3, BLUE, "Read");
|
|
+ jpprintf(6, 3, GREEN, ":");
|
|
+ jpprintf(7, 3, CYAN, "%i", my_read);
|
|
}
|
|
|
|
- jpprintf(1, 4, BLUE, "Total", tot);
|
|
- jprintf(GREEN, ":");
|
|
- jpprintf(7, 4, CYAN, "%i", tot);
|
|
+ jpprintf(1, 4, BLUE, "Total");
|
|
+ jpprintf(6, 4, GREEN, ":");
|
|
+ jpprintf(7, 4, CYAN, "%i", my_tot);
|
|
}
|
|
|
|
void do_expose() {
|
|
@@ -63,5 +100,6 @@
|
|
}
|
|
|
|
void do_button_release() {
|
|
- do_update();
|
|
+ system (my_app);
|
|
}
|
|
+
|