mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-12-26 04:17:33 +00:00
Extended support for local Maildir patch sf.net id #2561323 (thanks Nicolas).
This commit is contained in:
parent
f7aeae2c01
commit
cf77d3f1f9
@ -17,6 +17,8 @@
|
||||
Carpathia).
|
||||
* Fix shown battery status when the battery is not charging any more but
|
||||
is not full charged patch sf.net id #2556056 (thanks Martin)
|
||||
* Extended support for local Maildir patch sf.net id #2561323 (thanks
|
||||
Nicolas)
|
||||
|
||||
2009-02-15
|
||||
* Added out_to_x
|
||||
|
70
README
70
README
@ -1100,6 +1100,71 @@ conky(1) conky(1)
|
||||
your favourite protocol. See also new_mails.
|
||||
|
||||
|
||||
1mnew_mails (mailbox) (interval)0m
|
||||
Unread mail count in the specified mailbox or mail spool if not.
|
||||
Both mbox and maildir type mailboxes are supported.
|
||||
|
||||
|
||||
1mseen_mails (maildir) (interval)0m
|
||||
Number of mails marked as seen in the specified mailbox or mail
|
||||
spool if not. Only maildir type mailboxes are supported, mbox
|
||||
type will return -1.
|
||||
|
||||
|
||||
1munseen_mails (maildir) (interval)0m
|
||||
Number of new or unseen mails in the specified mailbox or mail
|
||||
spool if not. Only maildir type mailboxes are supported, mbox
|
||||
type will return -1.
|
||||
|
||||
|
||||
1mflagged_mails (maildir) (interval)0m
|
||||
Number of mails marked as flagged in the specified mailbox or
|
||||
mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1munflagged_mails (maildir) (interval)0m
|
||||
Number of mails not marked as flagged in the specified mailbox
|
||||
or mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1mforwarded_mails (maildir) (interval)0m
|
||||
Number of mails marked as forwarded in the specified mailbox or
|
||||
mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1munforwarded_mails (maildir) (interval)0m
|
||||
Number of mails not marked as forwarded in the specified mailbox
|
||||
or mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1mreplied_mails (maildir) (interval)0m
|
||||
Number of mails marked as replied in the specified mailbox or
|
||||
mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1munreplied_mails (maildir) (interval)0m
|
||||
Number of mails not marked as replied in the specified mailbox
|
||||
or mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1mdraft_mails (maildir) (interval)0m
|
||||
Number of mails marked as draft in the specified mailbox or mail
|
||||
spool if not. Only maildir type mailboxes are supported, mbox
|
||||
type will return -1.
|
||||
|
||||
|
||||
1mtrashed_mails (maildir) (interval)0m
|
||||
Number of mails marked as trashed in the specified mailbox or
|
||||
mail spool if not. Only maildir type mailboxes are supported,
|
||||
mbox type will return -1.
|
||||
|
||||
|
||||
1mmboxscan (-n number of messages to print) (-fw from width) (-sw subject0m
|
||||
1mwidth) mbox0m
|
||||
Print a summary of recent messages in an mbox format mailbox.
|
||||
@ -1300,11 +1365,6 @@ conky(1) conky(1)
|
||||
defaults to 0.
|
||||
|
||||
|
||||
1mnew_mails (mailbox) (interval)0m
|
||||
Unread mail count in the specified mailbox or mail spool if not.
|
||||
Both mbox and maildir type mailboxes are supported.
|
||||
|
||||
|
||||
1mnodename0m
|
||||
Hostname
|
||||
|
||||
|
60
doc/conky.1
60
doc/conky.1
@ -950,6 +950,61 @@ 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<\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<\fBseen_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails marked as seen in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBunseen_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of new or unseen mails in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBflagged_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails marked as flagged in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBunflagged_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails not marked as flagged in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBforwarded_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails marked as forwarded in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBunforwarded_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails not marked as forwarded in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBreplied_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails marked as replied in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBunreplied_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails not marked as replied in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBdraft_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails marked as draft in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBtrashed_mails\fR\*(T>\fR \*(T<\fB(maildir)\fR\*(T> \*(T<\fB(interval)\fR\*(T>
|
||||
Number of mails marked as trashed in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
|
||||
.TP
|
||||
\fB\*(T<\fBmboxscan\fR\*(T>\fR \*(T<\fB(\-n number of messages to print) (\-fw from width) (\-sw subject width) mbox\fR\*(T>
|
||||
Print a summary of recent messages in an mbox format mailbox. mbox parameter is the filename of the mailbox (can be encapsulated using '"', ie. ${mboxscan -n 10 "/home/brenden/some box"}
|
||||
@ -1130,11 +1185,6 @@ if mpd is playing or paused, display everything between $if_mpd_playing and the
|
||||
\fB\*(T<\fBnameserver\fR\*(T>\fR \*(T<\fB(index)\fR\*(T>
|
||||
Print a nameserver from /etc/resolv.conf. Index starts at and defaults to 0.
|
||||
|
||||
.TP
|
||||
\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
|
||||
Hostname
|
||||
|
@ -1216,6 +1216,138 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>new_mails</option></command>
|
||||
<option>(mailbox)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Unread mail count in the specified mailbox or mail spool if
|
||||
not. Both mbox and maildir type mailboxes are supported.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>seen_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails marked as seen in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>unseen_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of new or unseen mails in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>flagged_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails marked as flagged in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>unflagged_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails not marked as flagged in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>forwarded_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails marked as forwarded in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>unforwarded_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails not marked as forwarded in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>replied_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails marked as replied in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>unreplied_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails not marked as replied in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>draft_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails marked as draft in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>trashed_mails</option></command>
|
||||
<option>(maildir)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Number of mails marked as trashed in the specified mailbox or mail spool if
|
||||
not. Only maildir type mailboxes are supported, mbox type will return -1.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>mboxscan</option></command>
|
||||
@ -1634,18 +1766,6 @@
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>new_mails</option></command>
|
||||
<option>(mailbox)</option>
|
||||
<option>(interval)</option>
|
||||
</term>
|
||||
<listitem>
|
||||
Unread mail count in the specified mailbox or mail spool if
|
||||
not. Both mbox and maildir type mailboxes are supported.
|
||||
<para></para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry>
|
||||
<term>
|
||||
<command><option>nodename</option></command>
|
||||
|
279
src/conky.c
279
src/conky.c
@ -1252,6 +1252,16 @@ static void free_text_objects(struct text_object *root)
|
||||
break;
|
||||
case OBJ_mails:
|
||||
case OBJ_new_mails:
|
||||
case OBJ_seen_mails:
|
||||
case OBJ_unseen_mails:
|
||||
case OBJ_flagged_mails:
|
||||
case OBJ_unflagged_mails:
|
||||
case OBJ_forwarded_mails:
|
||||
case OBJ_unforwarded_mails:
|
||||
case OBJ_replied_mails:
|
||||
case OBJ_unreplied_mails:
|
||||
case OBJ_draft_mails:
|
||||
case OBJ_trashed_mails:
|
||||
free(data.local_mail.box);
|
||||
break;
|
||||
case OBJ_imap:
|
||||
@ -2600,6 +2610,193 @@ static struct text_object *construct_text_object(const char *s,
|
||||
}
|
||||
}
|
||||
|
||||
variable_substitute(box, dst, sizeof(dst));
|
||||
obj->data.local_mail.box = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(new_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(seen_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(unseen_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(flagged_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(unflagged_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(forwarded_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(unforwarded_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(replied_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(unreplied_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(draft_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(trashed_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
@ -2642,28 +2839,6 @@ static struct text_object *construct_text_object(const char *s,
|
||||
END OBJ(monitor, INFO_X11)
|
||||
END OBJ(monitor_number, INFO_X11)
|
||||
#endif
|
||||
END OBJ(new_mails, 0)
|
||||
float n1;
|
||||
char box[256], dst[256];
|
||||
|
||||
if (!arg) {
|
||||
n1 = 9.5;
|
||||
/* Kapil: Changed from MAIL_FILE to
|
||||
current_mail_spool since the latter
|
||||
is a copy of the former if undefined
|
||||
but the latter should take precedence
|
||||
if defined */
|
||||
strncpy(box, current_mail_spool, 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 = strndup(dst, text_buffer_size);
|
||||
obj->data.local_mail.interval = n1;
|
||||
END OBJ(nodename, 0)
|
||||
END OBJ(processes, INFO_PROCS)
|
||||
END OBJ(running_processes, INFO_RUN_PROCS)
|
||||
@ -4725,16 +4900,66 @@ static void generate_text_internal(char *p, int p_max_size,
|
||||
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) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.new_mail_count);
|
||||
}
|
||||
OBJ(seen_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.seen_mail_count);
|
||||
}
|
||||
OBJ(unseen_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.unseen_mail_count);
|
||||
}
|
||||
OBJ(flagged_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.flagged_mail_count);
|
||||
}
|
||||
OBJ(unflagged_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.unflagged_mail_count);
|
||||
}
|
||||
OBJ(forwarded_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.forwarded_mail_count);
|
||||
}
|
||||
OBJ(unforwarded_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.unforwarded_mail_count);
|
||||
}
|
||||
OBJ(replied_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.replied_mail_count);
|
||||
}
|
||||
OBJ(unreplied_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.unreplied_mail_count);
|
||||
}
|
||||
OBJ(draft_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.draft_mail_count);
|
||||
}
|
||||
OBJ(trashed_mails) {
|
||||
update_mail_count(&obj->data.local_mail);
|
||||
snprintf(p, p_max_size, "%d",
|
||||
obj->data.local_mail.trashed_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(nodename) {
|
||||
snprintf(p, p_max_size, "%s", cur->uname_s.nodename);
|
||||
}
|
||||
|
49
src/mail.c
49
src/mail.c
@ -87,8 +87,14 @@ void update_mail_count(struct local_mail_s *mail)
|
||||
DIR *dir;
|
||||
char *dirname;
|
||||
struct dirent *dirent;
|
||||
char *mailflags;
|
||||
|
||||
mail->mail_count = mail->new_mail_count = 0;
|
||||
mail->seen_mail_count = mail->unseen_mail_count = 0;
|
||||
mail->flagged_mail_count = mail->unflagged_mail_count = 0;
|
||||
mail->forwarded_mail_count = mail->unforwarded_mail_count = 0;
|
||||
mail->replied_mail_count = mail->unreplied_mail_count = 0;
|
||||
mail->draft_mail_count = mail->trashed_mail_count = 0;
|
||||
dirname = (char *) malloc(sizeof(char) * (strlen(mail->box) + 5));
|
||||
if (!dirname) {
|
||||
ERR("malloc");
|
||||
@ -110,6 +116,41 @@ void update_mail_count(struct local_mail_s *mail)
|
||||
/* . and .. are skipped */
|
||||
if (dirent->d_name[0] != '.') {
|
||||
mail->mail_count++;
|
||||
mailflags = (char *) malloc(sizeof(char) * strlen(strrchr(dirent->d_name, ',')));
|
||||
if (!mailflags) {
|
||||
ERR("malloc");
|
||||
free(dirname);
|
||||
return;
|
||||
}
|
||||
strcpy(mailflags, strrchr(dirent->d_name, ','));
|
||||
if (!strchr(mailflags, 'T')) { /* The message is not in the trash */
|
||||
if (strchr(mailflags, 'S')) { /*The message has been seen */
|
||||
mail->seen_mail_count++;
|
||||
} else {
|
||||
mail->unseen_mail_count++;
|
||||
}
|
||||
if (strchr(mailflags, 'F')) { /*The message was flagged */
|
||||
mail->flagged_mail_count++;
|
||||
} else {
|
||||
mail->unflagged_mail_count++;
|
||||
}
|
||||
if (strchr(mailflags, 'P')) { /*The message was forwarded */
|
||||
mail->forwarded_mail_count++;
|
||||
} else {
|
||||
mail->unforwarded_mail_count++;
|
||||
}
|
||||
if (strchr(mailflags, 'R')) { /*The message was replied */
|
||||
mail->replied_mail_count++;
|
||||
} else {
|
||||
mail->unreplied_mail_count++;
|
||||
}
|
||||
if (strchr(mailflags, 'D')) { /*The message is a draft */
|
||||
mail->draft_mail_count++;
|
||||
}
|
||||
} else {
|
||||
mail->trashed_mail_count++;
|
||||
}
|
||||
free(mailflags);
|
||||
}
|
||||
dirent = readdir(dir);
|
||||
}
|
||||
@ -130,6 +171,7 @@ void update_mail_count(struct local_mail_s *mail)
|
||||
if (dirent->d_name[0] != '.') {
|
||||
mail->new_mail_count++;
|
||||
mail->mail_count++;
|
||||
mail->unseen_mail_count++; /* new messages cannot have been seen */
|
||||
}
|
||||
dirent = readdir(dir);
|
||||
}
|
||||
@ -151,6 +193,13 @@ void update_mail_count(struct local_mail_s *mail)
|
||||
|
||||
mail->new_mail_count = mail->mail_count = 0;
|
||||
|
||||
/* these flags are not supported for mbox */
|
||||
mail->seen_mail_count = mail->unseen_mail_count = -1;
|
||||
mail->flagged_mail_count = mail->unflagged_mail_count = -1;
|
||||
mail->forwarded_mail_count = mail->unforwarded_mail_count = -1;
|
||||
mail->replied_mail_count = mail->unreplied_mail_count = -1;
|
||||
mail->draft_mail_count = mail->trashed_mail_count = -1;
|
||||
|
||||
fp = open_file(mail->box, &rep);
|
||||
if (!fp) {
|
||||
return;
|
||||
|
10
src/mail.h
10
src/mail.h
@ -27,6 +27,16 @@ struct local_mail_s {
|
||||
char *box;
|
||||
int mail_count;
|
||||
int new_mail_count;
|
||||
int seen_mail_count;
|
||||
int unseen_mail_count;
|
||||
int flagged_mail_count;
|
||||
int unflagged_mail_count;
|
||||
int forwarded_mail_count;
|
||||
int unforwarded_mail_count;
|
||||
int replied_mail_count;
|
||||
int unreplied_mail_count;
|
||||
int draft_mail_count;
|
||||
int trashed_mail_count;
|
||||
float interval;
|
||||
time_t last_mtime;
|
||||
double last_update;
|
||||
|
@ -170,6 +170,17 @@ enum text_object_type {
|
||||
OBJ_loadavg,
|
||||
OBJ_machine,
|
||||
OBJ_mails,
|
||||
OBJ_new_mails,
|
||||
OBJ_seen_mails,
|
||||
OBJ_unseen_mails,
|
||||
OBJ_flagged_mails,
|
||||
OBJ_unflagged_mails,
|
||||
OBJ_forwarded_mails,
|
||||
OBJ_unforwarded_mails,
|
||||
OBJ_replied_mails,
|
||||
OBJ_unreplied_mails,
|
||||
OBJ_draft_mails,
|
||||
OBJ_trashed_mails,
|
||||
OBJ_mboxscan,
|
||||
OBJ_mem,
|
||||
OBJ_memeasyfree,
|
||||
@ -191,7 +202,6 @@ enum text_object_type {
|
||||
OBJ_monitor_number,
|
||||
#endif
|
||||
OBJ_nameserver,
|
||||
OBJ_new_mails,
|
||||
OBJ_nodename,
|
||||
OBJ_nvidia,
|
||||
OBJ_pre_exec,
|
||||
|
Loading…
Reference in New Issue
Block a user