static struct mbox **mbox_array;
static int num_mboxes, mbox_array_size;
+struct osd_opt_node {
+ cnode n;
+ char *val;
+ char key[1];
+};
+
+static clist osd_opts;
+
static void redraw_line(int i);
static void rethink_display(void);
}
}
+static void
+add_osd_opt(char *arg)
+{
+ struct osd_opt_node *n = xmalloc(sizeof(*n) + strlen(arg));
+ strcpy(n->key, arg);
+ n->val = strchr(n->key, '=');
+ if (!n->val)
+ die("Malformed OSD option");
+ *n->val++ = 0;
+ clist_add_tail(&osd_opts, &n->n);
+}
+
static char *
mbox_name(char *path)
{
osd_pty = XInternAtom(x11_dpy, "OSD_QUEUE", False);
if (!osd_pty)
die("Cannot intern OSD_QUEUE atom");
+
+ // If OSD options contain no message, add one
+ int seen_msg = 0;
+ CLIST_FOR_EACH(struct osd_opt_node *, n, osd_opts)
+ if (!n->key[0])
+ seen_msg = 1;
+ if (!seen_msg)
+ add_osd_opt("=You have new mail");
}
leds_have = ~0U;
return;
debug("OSD: Displaying\n");
- char msg[] = ":You have new mail\n\n";
- XChangeProperty(x11_dpy, DefaultRootWindow(x11_dpy), osd_pty, XA_STRING, 8, PropModeAppend, (unsigned char *) msg, sizeof(msg)-1);
+ char msg[1024];
+ unsigned pos = 0;
+ CLIST_FOR_EACH(struct osd_opt_node *, n, osd_opts)
+ {
+ pos += snprintf(msg+pos, sizeof(msg)-pos-1, "%s:%s\n", n->key, n->val);
+ if (pos > sizeof(msg)-1)
+ {
+ pos = sprintf(msg, "OSD message too long!\n");
+ break;
+ }
+ }
+ msg[pos++] = '\n';
+
+ XChangeProperty(x11_dpy, DefaultRootWindow(x11_dpy), osd_pty, XA_STRING, 8, PropModeAppend, (unsigned char *) msg, pos);
XFlush(x11_dpy);
}
-o <pattern>=<opts>\tSet mailbox options\n\
-o <opts>\t\tSet default options for all mailboxes\n\
-p <pri>\t\tSet minimum priority to show\n\
+-s <key>=<val>\t\tSet on-screen display options (consult OSDD docs)\n\
\n\
Mailbox options (set with `-o', use upper case to negate):\n\
0-9\t\t\tSet mailbox priority (0=default)\n\
clist_init(&mboxes);
clist_init(&options);
clist_init(&patterns);
+ clist_init(&osd_opts);
int c;
- while ((c = getopt(argc, argv, "c:dim:o:p:")) >= 0)
+ while ((c = getopt(argc, argv, "c:dim:o:p:s:")) >= 0)
switch (c)
{
case 'c':
case 'p':
minimum_priority = atol(optarg);
break;
+ case 's':
+ add_osd_opt(optarg);
+ break;
default:
usage();
}