diff options
author | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-07-31 02:04:18 +0200 |
---|---|---|
committer | Lukas Fleischer <calcurse@cryptocrack.de> | 2011-07-31 03:23:32 +0200 |
commit | 45417bc6f0b6a38754bc707608c9b377d006cdfd (patch) | |
tree | 3afce6d731a33a60b6d82d207d5d18a0f87373f5 | |
parent | 0884d62b2282b3ff5936f8d36f7f8d77c504938d (diff) | |
download | calcurse-45417bc6f0b6a38754bc707608c9b377d006cdfd.zip |
Add configuration option to notify all appointments
If "notify-all" is enabled, all non-flagged appointments will be
notified (instead of flagged ones). This is useful for users that want
to be notified of everything.
Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
-rw-r--r-- | doc/manual.txt | 4 | ||||
-rw-r--r-- | src/calcurse.h | 1 | ||||
-rw-r--r-- | src/custom.c | 5 | ||||
-rw-r--r-- | src/io.c | 4 | ||||
-rw-r--r-- | src/notify.c | 26 |
5 files changed, 35 insertions, 5 deletions
diff --git a/doc/manual.txt b/doc/manual.txt index 6bf7637..b2b80b0 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -804,6 +804,10 @@ $ calcurse --next | mail -s "[calcurse] upcoming appointment!" user@host.com ---- ==== +`notify-all` (default: *no*):: + Invert the sense of flagging an appointment as `important`. If this is + enabled, all appointments will be notified - except for flagged ones. + `notify-daemon_enable` (default: *no*):: If set to yes, daemon mode will be enabled, meaning `calcurse` will run into background when the user's interface is exited. This will allow the diff --git a/src/calcurse.h b/src/calcurse.h index 1a63657..b1b8e75 100644 --- a/src/calcurse.h +++ b/src/calcurse.h @@ -466,6 +466,7 @@ struct nbar { char timefmt[BUFSIZ]; /* format for displaying time */ char cmd[BUFSIZ]; /* notification command */ char *shell; /* user shell to launch notif. cmd */ + unsigned notify_all; /* notify all appointments */ pthread_mutex_t mutex; }; diff --git a/src/custom.c b/src/custom.c index 6385593..b2679d2 100644 --- a/src/custom.c +++ b/src/custom.c @@ -59,6 +59,7 @@ enum conf_var { CUSTOM_CONF_NOTIFYBARCLOCK, CUSTOM_CONF_NOTIFYBARWARNING, CUSTOM_CONF_NOTIFYBARCOMMAND, + CUSTOM_CONF_NOTIFYALL, CUSTOM_CONF_OUTPUTDATEFMT, CUSTOM_CONF_INPUTDATEFMT, CUSTOM_CONF_DMON_ENABLE, @@ -89,6 +90,7 @@ static struct conf_varname conf_varmap[] = { CUSTOM_CONF_NOTIFYBARCLOCK, "notify-bar_clock" }, { CUSTOM_CONF_NOTIFYBARWARNING, "notify-bar_warning" }, { CUSTOM_CONF_NOTIFYBARCOMMAND, "notify-bar_command" }, + { CUSTOM_CONF_NOTIFYALL, "notify-all" }, { CUSTOM_CONF_OUTPUTDATEFMT, "output_datefmt" }, { CUSTOM_CONF_INPUTDATEFMT, "input_datefmt" }, { CUSTOM_CONF_DMON_ENABLE, "notify-daemon_enable" }, @@ -338,6 +340,9 @@ custom_set_conf (struct conf *conf, enum conf_var var, char *val) case CUSTOM_CONF_NOTIFYBARCOMMAND: (void)strncpy (nbar.cmd, val, strlen (val) + 1); break; + case CUSTOM_CONF_NOTIFYALL: + return conf_parse_bool (&nbar.notify_all, val); + break; case CUSTOM_CONF_OUTPUTDATEFMT: if (val[0] != '\0') (void)strncpy (conf->output_datefmt, val, strlen (val) + 1); @@ -944,6 +944,10 @@ io_save_conf (struct conf *conf) (void)fprintf (fp, "notify-bar_command="); (void)fprintf (fp, "%s\n", nbar.cmd); + (void)fprintf (fp, "\n# Notify all appointments instead of flagged ones only\n"); + (void)fprintf (fp, "notify-all="); + (void)fprintf (fp, "%s\n", (nbar.notify_all) ? "yes" : "no"); + (void)fprintf (fp, "\n# Format of the date to be displayed " "in non-interactive mode :\n"); (void)fprintf (fp, "output_datefmt="); diff --git a/src/notify.c b/src/notify.c index 1b7e924..590a3e4 100644 --- a/src/notify.c +++ b/src/notify.c @@ -80,7 +80,8 @@ unsigned notify_needs_reminder (void) { if (notify_app.got_app - && (notify_app.state & APOINT_NOTIFY) + && (((notify_app.state & APOINT_NOTIFY) && !nbar.notify_all) || + (!(notify_app.state & APOINT_NOTIFY) && nbar.notify_all)) && !(notify_app.state & APOINT_NOTIFIED)) return 1; return 0; @@ -132,6 +133,8 @@ notify_init_vars (void) if ((nbar.shell = getenv ("SHELL")) == NULL) nbar.shell = "/bin/sh"; + nbar.notify_all = 0; + (void)pthread_attr_init (&detached_thread_attr); (void)pthread_attr_setdetachstate (&detached_thread_attr, PTHREAD_CREATE_DETACHED); @@ -281,7 +284,9 @@ notify_update_bar (void) minutes_left = (time_left - hours_left * HOURINSEC) / MININSEC; pthread_mutex_lock (&nbar.mutex); - if (time_left < nbar.cntdwn && (notify_app.state & APOINT_NOTIFY)) + if (time_left < nbar.cntdwn && + (((notify_app.state & APOINT_NOTIFY) && !nbar.notify_all) || + (!(notify_app.state & APOINT_NOTIFY) && nbar.notify_all))) blinking = 1; else blinking = 0; @@ -619,7 +624,7 @@ print_config_options (WINDOW *optwin) const int YOFF = 3; enum - { SHOW, DATE, CLOCK, WARN, CMD, DMON, DMON_LOG, NB_OPT }; + { SHOW, DATE, CLOCK, WARN, CMD, NOTIFY_ALL, DMON, DMON_LOG, NB_OPT }; struct opt_s { @@ -647,6 +652,9 @@ print_config_options (WINDOW *optwin) opt[CMD].name = _("notify-bar_command = "); opt[CMD].desc = _("(Command used to notify user of an upcoming appointment)"); + opt[NOTIFY_ALL].name = _("notify-all = "); + opt[NOTIFY_ALL].desc = _("(Notify all appointments instead of flagged ones only)"); + opt[DMON].name = _("notify-daemon_enable = "); opt[DMON].desc = _("(Run in background to get notifications after exiting)"); @@ -663,12 +671,14 @@ print_config_options (WINDOW *optwin) /* Boolean options */ opt[SHOW].valnum = nbar.show; + opt[NOTIFY_ALL].valnum = nbar.notify_all; pthread_mutex_unlock (&nbar.mutex); opt[DMON].valnum = dmon.enable; opt[DMON_LOG].valnum = dmon.log; - opt[SHOW].valstr[0] = opt[DMON].valstr[0] = opt[DMON_LOG].valstr[0] = '\0'; + opt[SHOW].valstr[0] = opt[NOTIFY_ALL].valstr[0] = opt[DMON].valstr[0] = + opt[DMON_LOG].valstr[0] = '\0'; for (i = 0; i < NB_OPT; i++) { @@ -797,9 +807,15 @@ notify_config_bar (void) } break; case '6': - dmon.enable = !dmon.enable; + pthread_mutex_lock (&nbar.mutex); + nbar.notify_all = !nbar.notify_all; + pthread_mutex_unlock (&nbar.mutex); + notify_check_next_app (1); break; case '7': + dmon.enable = !dmon.enable; + break; + case '8': dmon.log = !dmon.log; break; } |