mdeutils/mbiff/mail.c
2025-11-25 11:16:05 +09:00

36 lines
735 B
C

#include "mbiff.h"
static time_t last = 0;
static char* mailpath;
void init_mail(void) {
struct stat s;
char* name = MDEUsersGetUsername();
if(getenv("MAIL") != NULL) {
mailpath = malloc(strlen(getenv("MAIL")) + strlen(name) + 1);
sprintf(mailpath, getenv("MAIL"), name);
} else {
mailpath = malloc(strlen(_PATH_MAILDIR) + 1 + strlen(name) + 1);
sprintf(mailpath, _PATH_MAILDIR "/%s", name);
}
free(name);
if(stat(mailpath, &s) == 0) {
last = s.st_mtime;
}
}
void check_mail(void) {
struct stat s;
s.st_mtime = 0;
if(stat(mailpath, &s) == 0 || last != 0) {
if((s.st_mtime == 0 && last != 0) || s.st_mtime > last) {
MwVaApply(image,
MwNpixmap, full,
NULL);
}
last = s.st_mtime;
}
}