diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-28 00:02:15 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-28 00:04:00 +0100 |
commit | 6061fec01d8c34e38cd5921f629e560c1222aa01 (patch) | |
tree | cd0f4a9971414c32adc855a263bd123e7b4f53ab /src | |
parent | d127ce944774e500daff4453f0f12bb689d0f3f7 (diff) | |
download | calcurse-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>
Diffstat (limited to 'src')
-rw-r--r-- | src/args.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -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; |