/* * Copyright (C) 2002 Ronald Kuetemeier * * This program is free software; you can redistribute it and/or * modify it under the terms of version 2 of the GNU General Public * License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. */ #define _GNU_SOURCE /* needed to get the defines */ #include /* in glibc 2.2 this has the needed values defined */ #include #include #include #include #include #include #include #include static volatile int counter = 0; static struct itimerval itimer; static void handler(int sig, siginfo_t *si, void *data) { if (counter == 0){ itimer.it_value.tv_sec = 0; itimer.it_value.tv_usec = 50 * 1000; setitimer(ITIMER_REAL,&itimer,NULL) ; counter++; } else counter++; return ; } static void alr_handler(int sig, siginfo_t *si, void *data) { counter = 0; return ; } int main(void) { struct sigaction act, alr; int fd,fd1, tone,tone_length, tone_freq; struct stat buff; off_t file_length = 0; act.sa_sigaction = handler; sigemptyset(&act.sa_mask); act.sa_flags = SA_SIGINFO; sigaction(SIGRTMIN, &act, NULL); alr.sa_sigaction = alr_handler; sigemptyset(&alr.sa_mask); alr.sa_flags = SA_SIGINFO; sigaction(SIGALRM, &alr, NULL); //Change the dir path, i.e XXXXXXX fd = open("/home/XXXXXXX/evolution/local/Inbox", O_RDONLY); fd1 = open("/dev/tty0", O_RDWR); fcntl(fd, F_SETSIG, SIGRTMIN); fcntl(fd, F_NOTIFY, DN_MODIFY|DN_MULTISHOT); tone_length = 500; tone_freq = 850; tone = (tone_length<<16)+(1193180/tone_freq); while (1) { //counter for normal evolution house keeping, i.e don't beep when no new mail if(counter > 5 ){ //Change the file path; replace XXXXXX ... stat("/home/XXXXXXXX/evolution/local/Inbox/mbox",&buff); if(buff.st_size > file_length){ ioctl(fd1, KDMKTONE,tone); } file_length = buff.st_size; } pause(); } close(fd); close(fd1); return 0; }