From 6061fec01d8c34e38cd5921f629e560c1222aa01 Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 28 Jan 2016 00:02:15 +0100 Subject: Add a --daemon command-line parameter When specifying --daemon, calcurse immediately forks and runs the notification daemon in the background. Signed-off-by: Lukas Fleischer --- doc/manual.txt | 4 ++++ src/args.c | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/doc/manual.txt b/doc/manual.txt index 3266ecb..a388fe0 100644 --- a/doc/manual.txt +++ b/doc/manual.txt @@ -200,6 +200,10 @@ second form is equivalent to `-Q --filter-type cal --days `. Note: as for the `-a` flag, the calendar from which to read the appointments can be specified using the `-c` flag. +`--daemon`:: + Start calcurse in background mode. See <> for + details. + `--days `:: Specify the length of the range (in days) when used with `-Q`. Cannot be combined with `--to`. diff --git a/src/args.c b/src/args.c index 003760d..d40b470 100644 --- a/src/args.c +++ b/src/args.c @@ -73,7 +73,8 @@ enum { OPT_LIST_IMPORTED, OPT_EXPORT_UID, OPT_READ_ONLY, - OPT_STATUS + OPT_STATUS, + OPT_DAEMON }; /* @@ -439,7 +440,7 @@ int parse_args(int argc, char **argv) { /* Command-line flags */ int grep = 0, grep_filter = 0, query = 0, next = 0; - int status = 0, gc = 0, import = 0, export = 0; + int status = 0, gc = 0, import = 0, export = 0, daemon = 0; /* Query ranges */ time_t from = -1, to = -1; int range = -1; @@ -514,6 +515,7 @@ int parse_args(int argc, char **argv) {"list-imported", no_argument, NULL, OPT_LIST_IMPORTED}, {"read-only", no_argument, NULL, OPT_READ_ONLY}, {"status", no_argument, NULL, OPT_STATUS}, + {"daemon", no_argument, NULL, OPT_DAEMON}, {NULL, no_argument, NULL, 0} }; @@ -730,6 +732,9 @@ int parse_args(int argc, char **argv) case OPT_STATUS: status = 1; break; + case OPT_DAEMON: + daemon = 1; + break; default: usage(); usage_try(); @@ -741,7 +746,7 @@ int parse_args(int argc, char **argv) if (filter.type_mask == 0) filter.type_mask = TYPE_MASK_ALL; - if (status + grep + query + next + gc + import + export > 1) { + if (status + grep + query + next + gc + import + export + daemon > 1) { ERROR_MSG(_("invalid argument combination")); usage(); usage_try(); @@ -808,6 +813,9 @@ int parse_args(int argc, char **argv) io_check_file(path_todo); io_load_data(&filter); io_export_data(xfmt, export_uid); + } else if (daemon) { + notify_init_vars(); + dmon_start(0); } else { /* interactive mode */ non_interactive = 0; -- cgit v1.2.3