wmshutdown: Add freedesktop.org desktop entry file.
[dockapps.git] / wmjmail / src / Andre.Merzky.patch
blobc543608578a0b5b9998b6e8a421148ca57bb4fef
1 --- wmjmail.c Tue Nov 30 07:36:05 1999
2 +++ wmjmail.new Wed Mar 28 07:40:06 2001
3 @@ -3,7 +3,22 @@
4 #include <getopt.h>
5 #include "jenglish.h"
7 -int dontread = 0;
8 +#include <errno.h>
9 +#include <fcntl.h>
10 +#include <stdio.h>
11 +#include <unistd.h>
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 &"
19 +int dontread = 0;
20 +static char my_folder[256];
21 +static char my_app[256];
22 +static int my_new, my_tot, my_read;
23 +static off_t size;
25 void show_help() {
26 printf("-s <sec>: Seconds between executions of mailchk\n");
27 @@ -15,47 +30,69 @@
28 void setup(int argc, char** argv) {
29 char c;
30 int i;
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:"))) {
37 switch(c) {
38 case '?': exit(1);
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 */
52 void do_update() {
53 - int i, new, tot, read;
55 - FILE *f = popen("mailchk", "r");
56 - fscanf(f, "%i - %i - %i", &new, &tot, &read);
57 - pclose(f);
58 + int i;
59 + int in;
60 + struct stat buf;
62 + fprintf (stderr, "Stat '%s'\n", my_folder);
63 + if ( stat (my_folder, &buf) != 0 )
64 + {
65 + perror ("");
66 + fprintf (stderr, "Could not stat '%s'\n", my_folder);
67 + exit (-2);
68 + }
70 + if ( size != buf.st_size )
71 + {
72 + FILE *f = popen ("mailchk", "r");
73 + fscanf (f, "%i - %i - %i", &my_new, &my_tot, &my_read);
74 + pclose (f);
76 + size = buf.st_size;
77 + }
79 clear_window();
81 jpprintf(0, 0, YELLOW, " J-mail");
83 - jpprintf(1, 2, BLUE, "New", new);
84 - jprintf(GREEN, ":");
85 - if(new) {
86 - jpprintf(7, 2, RED, "%i", new);
87 + jpprintf(1, 2, BLUE, "New");
88 + jpprintf(6, 2, GREEN, ":");
89 + if (my_new) {
90 + jpprintf(7, 2, RED, "%i", my_new);
91 } else {
92 - jpprintf(7, 2, CYAN, "%i", new);
93 + jpprintf(7, 2, CYAN, "%i", my_new);
96 - if(!dontread) {
97 - jpprintf(1, 3, BLUE, "Read", read);
98 - jprintf(GREEN, ":");
99 - jpprintf(7, 3, CYAN, "%i", read);
100 + if (!dontread) {
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);
114 void do_expose() {
115 @@ -63,5 +100,6 @@
118 void do_button_release() {
119 - do_update();
120 + system (my_app);