Ben Kibbey <benkibbey at users dot sourceforge dot net>
$tail fifo patch
+ multiple mailbox patch
Blondak <blondak_nesercz at users dot sourceforge dot net>
diskio read & write patch
# $Id$
+2007-10-02
+ * Multiple mailbox patch (thanks Ben Kibbey)
+
2007-09-28
* Small fix for $ibm_volume (thanks Kapil Hari Paranjape)
* Patch so $tail can read from a fifo file descriptor (thanks Ben Kibbey)
Machine, i686 for example
- mails Mail count in mail spool. You can use program like fetchmail to
- get mails from some server using your favourite protocol. See
- also new_mails.
+ mails (mailbox) (interval)
+ Mail count in the specified mailbox or your mail spool if not.
+ Both mbox and maildir type mailboxes are supported. You can use
+ a program like fetchmail to get mails from some server using
+ your favourite protocol. See also new_mails.
mboxscan (-n number of messages to print) (-fw from width) (-sw subject
width) mbox
- Print a summary of recent messages in an mbox format mailbox.
- mbox parameter is the filename of the mailbox (can be encapsu-
+ Print a summary of recent messages in an mbox format mailbox.
+ mbox parameter is the filename of the mailbox (can be encapsu-
lated using '"', ie. ${mboxscan -n 10 "/home/brenden/some box"}
name, depending on whats available
- new_mails
- Unread mail count in mail spool.
+ new_mails (mailbox) (interval)
+ Unread mail count in the specified mailbox or mail spool if not.
+ Both mbox and maildir type mailboxes are supported.
nodename
Machine, i686 for example
.TP
-\fB\*(T<\fBmails\fR\*(T>\fR
-Mail count in mail spool. You can use program like fetchmail to get mails from some server using your favourite protocol. See also new_mails.
+\fB\*(T<\fBmails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
+Mail count in the specified mailbox or your mail spool if not.
+Both mbox and maildir type mailboxes are supported. You can
+use a program like fetchmail to get mails from some server
+using your favourite protocol. See also new_mails.
.TP
\fB\*(T<\fBmboxscan\fR\*(T>\fR \*(T<\fB(\-n number of messages to print) (\-fw from width) (\-sw subject width) mbox\fR\*(T>
Prints the song name in either the form "artist - title" or file name, depending on whats available
.TP
-\fB\*(T<\fBnew_mails\fR\*(T>\fR
-Unread mail count in mail spool.
+\fB\*(T<\fBnew_mails\fR\*(T>\fR \*(T<\fB(mailbox)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
+Unread mail count in the specified mailbox or mail spool if
+not. Both mbox and maildir type mailboxes are supported.
.TP
\fB\*(T<\fBnodename\fR\*(T>\fR
<varlistentry>
<term>
<command><option>mails</option></command>
+ <option>(mailbox)</option>
+ <option>(interval)</option>
</term>
<listitem>
- Mail count in mail spool. You can use program like fetchmail to get mails from some server using your favourite protocol. See also new_mails.
+ Mail count in the specified mailbox or your mail spool if not.
+ Both mbox and maildir type mailboxes are supported. You can
+ use a program like fetchmail to get mails from some server
+ using your favourite protocol. See also new_mails.
<para></para></listitem>
</varlistentry>
<varlistentry>
<term>
<command><option>new_mails</option></command>
+ <option>(mailbox)</option>
+ <option>(interval)</option>
</term>
<listitem>
- Unread mail count in mail spool.
+ Unread mail count in the specified mailbox or mail spool if
+ not. Both mbox and maildir type mailboxes are supported.
<para></para></listitem>
</varlistentry>
if (NEED(INFO_DISKIO))
update_diskio();
- if (NEED(INFO_MAIL))
- update_mail_count();
-
#if defined(__linux__)
if (NEED(INFO_I8K))
update_i8k();
int delay;
} rss;
#endif
+ struct local_mail_s local_mail;
} data;
};
free(objs[i].data.mboxscan.args);
free(objs[i].data.mboxscan.output);
break;
+ case OBJ_mails:
+ case OBJ_new_mails:
+ free(objs[i].data.local_mail.box);
+ break;
case OBJ_imap:
free(info.mail);
break;
blockdepth++;
END OBJ(kernel, 0)
END OBJ(machine, 0)
- END OBJ(mails, INFO_MAIL)
+ END OBJ(mails, 0) {
+ float n1;
+ char box[256], dst[256];
+
+ if (!arg) {
+ n1 = 9.5;
+ strncpy(box, MAIL_FILE, sizeof(box));
+ }
+ else {
+ if (sscanf(arg, "%s %f", box, &n1) != 2) {
+ n1 = 9.5;
+ strncpy(box, arg, sizeof(box));
+ }
+ }
+
+ variable_substitute(box, dst, sizeof(dst));
+ obj->data.local_mail.box = strdup(dst);
+ obj->data.local_mail.interval = n1;
+ }
+
END OBJ(mboxscan, 0)
obj->data.mboxscan.args = (char*)malloc(TEXT_BUFFER_SIZE);
obj->data.mboxscan.output = (char*)malloc(text_buffer_size);
scan_mixer_bar(arg, &obj->data.mixerbar.l,
&obj->data.mixerbar.w, &obj->data.mixerbar.h);
END
- OBJ(new_mails, INFO_MAIL)
+ OBJ(new_mails, 0) {
+ float n1;
+ char box[256], dst[256];
+
+ if (!arg) {
+ n1 = 9.5;
+ strncpy(box, MAIL_FILE, sizeof(box));
+ }
+ else {
+ if (sscanf(arg, "%s %f", box, &n1) != 2) {
+ n1 = 9.5;
+ strncpy(box, arg, sizeof(box));
+ }
+ }
+
+ variable_substitute(box, dst, sizeof(dst));
+ obj->data.local_mail.box = strdup(dst);
+ obj->data.local_mail.interval = n1;
+ }
+
END OBJ(nodename, 0)
END OBJ(processes, INFO_PROCS)
END OBJ(running_processes, INFO_RUN_PROCS)
/* mail stuff */
OBJ(mails) {
- snprintf(p, p_max_size, "%d", cur->mail_count);
+ update_mail_count(&obj->data.local_mail);
+ snprintf(p, p_max_size, "%d", obj->data.local_mail.mail_count);
}
OBJ(mboxscan) {
mbox_scan(obj->data.mboxscan.args, obj->data.mboxscan.output, TEXT_BUFFER_SIZE);
snprintf(p, p_max_size, "%s", obj->data.mboxscan.output);
}
OBJ(new_mails) {
- snprintf(p, p_max_size, "%d", cur->new_mail_count);
+ update_mail_count(&obj->data.local_mail);
+ snprintf(p, p_max_size, "%d", obj->data.local_mail.new_mail_count);
}
OBJ(nodename) {
free(text);
free(current_config);
- free(current_mail_spool);
#ifdef TCP_PORT_MONITOR
destroy_tcp_port_monitor_collection( info.p_tcp_port_monitor_collection );
float loadavg[3];
- int new_mail_count, mail_count;
struct mail_s* mail;
int mail_running;
#ifdef MPD
float totalmem;
};
+struct local_mail_s {
+ char *box;
+ int mail_count;
+ int new_mail_count;
+ float interval;
+ time_t last_mtime;
+ double last_update;
+};
+
void update_top();
void free_all_processes();
struct process *get_first_process();
char *current_mail_spool;
-static time_t last_mail_mtime;
-static double last_mail_update;
-
-void update_mail_count()
+void update_mail_count(struct local_mail_s *mail)
{
struct stat buf;
- if (current_mail_spool == NULL)
+ if (mail == NULL)
return;
/* TODO: use that fine file modification notify on Linux 2.4 */
/* don't check mail so often (9.5s is minimum interval) */
- if (current_update_time - last_mail_update < 9.5)
+ if (current_update_time - mail->last_update < 9.5)
return;
else
- last_mail_update = current_update_time;
+ mail->last_update = current_update_time;
- if (stat(current_mail_spool, &buf)) {
+ if (stat(mail->box, &buf)) {
static int rep;
if (!rep) {
- ERR("can't stat %s: %s", current_mail_spool,
+ ERR("can't stat %s: %s", mail->box,
strerror(errno));
rep = 1;
}
DIR *dir;
char *dirname;
struct dirent *dirent;
- info.mail_count = 0;
- info.new_mail_count = 0;
+ mail->mail_count = mail->new_mail_count = 0;
dirname =
(char *) malloc(sizeof(char) *
- (strlen(current_mail_spool) + 5));
+ (strlen(mail->box) + 5));
if (!dirname) {
ERR("malloc");
return;
}
- strcpy(dirname, current_mail_spool);
+ strcpy(dirname, mail->box);
strcat(dirname, "/");
/* checking the cur subdirectory */
strcat(dirname, "cur");
while (dirent) {
/* . and .. are skipped */
if (dirent->d_name[0] != '.') {
- info.mail_count++;
+ mail->mail_count++;
}
dirent = readdir(dir);
}
while (dirent) {
/* . and .. are skipped */
if (dirent->d_name[0] != '.') {
- info.new_mail_count++;
- info.mail_count++;
+ mail->new_mail_count++;
+ mail->mail_count++;
}
dirent = readdir(dir);
}
}
#endif
/* mbox format */
- if (buf.st_mtime != last_mail_mtime) {
+ if (buf.st_mtime != mail->last_mtime) {
/* yippee, modification time has changed, let's read mail count! */
static int rep;
FILE *fp;
/* could lock here but I don't think it's really worth it because
* this isn't going to write mail spool */
- info.new_mail_count = 0;
- info.mail_count = 0;
+ mail->new_mail_count = mail->mail_count = 0;
- fp = open_file(current_mail_spool, &rep);
+ fp = open_file(mail->box, &rep);
if (!fp)
return;
/* ignore MAILER-DAEMON */
if (strncmp(buf + 5, "MAILER-DAEMON ", 14)
!= 0) {
- info.mail_count++;
+ mail->mail_count++;
if (reading_status)
- info.new_mail_count++;
+ mail->new_mail_count++;
else
reading_status = 1;
}
17) == 0) {
/* check that mail isn't already read */
if (strchr(buf + 21, '0'))
- info.new_mail_count++;
+ mail->new_mail_count++;
reading_status = 0;
continue;
&& strncmp(buf, "Status:", 7) == 0) {
/* check that mail isn't already read */
if (strchr(buf + 7, 'R') == NULL)
- info.new_mail_count++;
+ mail->new_mail_count++;
reading_status = 0;
continue;
fclose(fp);
if (reading_status)
- info.new_mail_count++;
+ mail->new_mail_count++;
- last_mail_mtime = buf.st_mtime;
+ mail->last_mtime = buf.st_mtime;
}
}