summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-28 00:02:15 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-28 00:04:00 +0100
commit6061fec01d8c34e38cd5921f629e560c1222aa01 (patch)
treecd0f4a9971414c32adc855a263bd123e7b4f53ab
parentd127ce944774e500daff4453f0f12bb689d0f3f7 (diff)
downloadcalcurse-6061fec01d8c34e38cd5921f629e560c1222aa01.zip
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 <lfleischer@calcurse.org>
-rw-r--r--doc/manual.txt4
-rw-r--r--src/args.c14
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 <num>`.
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 <<basics_daemon,Background mode>> for
+ details.
+
`--days <num>`::
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;