wmclockmon: fix typos pointed out by Lintian.
[dockapps.git] / wmjmail / src / Andre.Merzky.audio.patch
blob32324b135c159908b3a601472b4a89c63beaf151
1 --- wmjmail.c Wed Mar 28 08:25:15 2001
2 +++ wmjmail.c.3 Wed Mar 28 08:20:43 2001
3 @@ -11,41 +11,56 @@
4 #include <sys/time.h>
5 #include <sys/types.h>
7 +#define AUDIOPLAYER "/usr/bin/play"
8 +#define AUDIOFILE "/usr/share/audio/clink.au"
9 #define SPOOLDIR "/var/spool/mail/"
10 #define APPLICATION "xterm -sb -sl 2000 +si +sk -title XTerm -fg black -bg wheat -geometry 71x50-0-0 -e mutt &"
12 int dontread = 0;
13 static char my_folder[256];
14 static char my_app[256];
15 +static char my_audio[512];
16 static int my_new, my_tot, my_read;
17 static off_t size;
19 void show_help() {
20 - printf("-s <sec>: Seconds between executions of mailchk\n");
21 - printf("-r : Don't show the read mail stat.\n");
22 + printf("-r : Don't show the read mail stat.\n");
23 + printf("-s <sec> : Seconds between executions of mailchk\n");
24 + printf("-x <exe> : Program to execute on button click \n");
25 + printf("-f <folder>: Mail folder to watch \n");
26 + printf("-P <player>: Audio player to use for notification \n");
27 + printf("-p <afile> : Audio file to play for notification \n");
29 exit(0);
32 void setup(int argc, char** argv) {
33 - char c;
34 - int i;
35 + char c;
36 + int i;
37 + char my_aplayer[256];
38 + char my_afile[256];
40 + snprintf (my_app, 255, "%s", APPLICATION);
41 + snprintf (my_folder, 255, "%s/%s", SPOOLDIR, getenv("USER"));
42 + snprintf (my_aplayer, 255, "%s", AUDIOPLAYER);
43 + snprintf (my_afile, 255, "%s", AUDIOFILE);
45 - snprintf (my_app, 255, "%s", APPLICATION);
46 - snprintf (my_folder, 255, "%s/%s", SPOOLDIR, getenv("USER"));
48 - while( -1 != (c = getopt(argc, argv, "hrs:x:f:"))) {
49 + while( -1 != (c = getopt(argc, argv, "hrs:x:f:P:p:"))) {
50 switch(c) {
51 case '?': exit(1);
52 case 'h': show_help();
54 case 'r': dontread = 1; break;
55 case 's': i=atoi(optarg); break;
56 - case 'x': snprintf (my_app, 255, "%s", optarg); break;
57 - case 'f': snprintf (my_folder, 255, "%s", optarg); break;
58 + case 'x': snprintf (my_app, 255, "%s", optarg); break;
59 + case 'f': snprintf (my_folder, 255, "%s", optarg); break;
60 + case 'p': snprintf (my_afile, 255, "%s", optarg); break;
61 + case 'P': snprintf (my_aplayer, 255, "%s", optarg); break;
65 + snprintf (my_audio, 511, "%s %s &", my_aplayer, my_afile);
67 set_update_delay((i) ? i : 15); /* seconds */
68 set_loop_delay(1000); /* mu seconds */
70 @@ -55,7 +70,6 @@
71 int in;
72 struct stat buf;
74 - fprintf (stderr, "Stat '%s'\n", my_folder);
75 if ( stat (my_folder, &buf) != 0 )
77 perror ("");
78 @@ -68,6 +82,13 @@
79 FILE *f = popen ("mailchk", "r");
80 fscanf (f, "%i - %i - %i", &my_new, &my_tot, &my_read);
81 pclose (f);
83 + /* Do not play on startup, and only on NEW mails */
84 + if ( size != 0 &&
85 + size < buf.st_size )
86 + {
87 + system (my_audio);
88 + }
90 size = buf.st_size;