Add pre-save and post-save hooks

This adds support for hooks which are executed before/after saving
calcurse data. Hooks can be placed under hooks/pre-save and
hooks/post-save in the data directory and need to be executable.

Potential use cases include:

* Automatically commit any changes to the data files using a VCS.
* Automatically sync with some sever component on data file changes.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer
2016-01-07 18:23:09 +01:00
parent ddfe49d9fe
commit 767214e4f1
5 changed files with 75 additions and 0 deletions

View File

@@ -93,6 +93,7 @@
#define DPID_PATH_NAME ".daemon.pid"
#define DLOG_PATH_NAME "daemon.log"
#define NOTES_DIR_NAME "notes/"
#define HOOKS_DIR_NAME "hooks/"
#define TODO_PATH DIR_NAME TODO_PATH_NAME
#define APTS_PATH DIR_NAME APTS_PATH_NAME
@@ -102,6 +103,7 @@
#define DLOG_PATH DIR_NAME DLOG_PATH_NAME
#define DPID_PATH DIR_NAME DPID_PATH_NAME
#define NOTES_DIR DIR_NAME NOTES_DIR_NAME
#define HOOKS_DIR DIR_NAME HOOKS_DIR_NAME
#define DEFAULT_EDITOR "vi"
#define DEFAULT_PAGER "less"
@@ -779,6 +781,9 @@ int updatestring(WINDOW *, char **, int, int);
/* help.c */
int display_help(const char *);
/* hooks.c */
int run_hook(const char *);
/* ical.c */
void ical_import_data(FILE *, FILE *, unsigned *, unsigned *, unsigned *,
unsigned *, unsigned *);
@@ -1111,6 +1116,7 @@ extern char path_notes[BUFSIZ];
extern char path_cpid[BUFSIZ];
extern char path_dpid[BUFSIZ];
extern char path_dmon_log[BUFSIZ];
extern char path_hooks[BUFSIZ];
extern struct conf conf;
extern struct pad apad;
extern struct nbar nbar;