diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-07 18:23:09 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-01-07 19:09:46 +0100 |
commit | 767214e4f157ae4a74be0b557bd49e24d972970b (patch) | |
tree | 46ee50d0e2c729e2892db8c96abc61294980a5fe /src/io.c | |
parent | ddfe49d9feeba0d280e501f67cda64646e79d901 (diff) | |
download | calcurse-767214e4f157ae4a74be0b557bd49e24d972970b.zip |
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>
Diffstat (limited to 'src/io.c')
-rw-r--r-- | src/io.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -239,6 +239,7 @@ void io_init(const char *cfile, const char *datadir) snprintf(path_dpid, BUFSIZ, "%s/" DPID_PATH_NAME, home); snprintf(path_dmon_log, BUFSIZ, "%s/" DLOG_PATH_NAME, home); + snprintf(path_hooks, BUFSIZ, "%s/" HOOKS_DIR_NAME, home); } else { home = getenv("HOME"); if (home == NULL) { @@ -252,6 +253,7 @@ void io_init(const char *cfile, const char *datadir) snprintf(path_dpid, BUFSIZ, "%s/" DPID_PATH, home); snprintf(path_dmon_log, BUFSIZ, "%s/" DLOG_PATH, home); snprintf(path_notes, BUFSIZ, "%s/" NOTES_DIR, home); + snprintf(path_hooks, BUFSIZ, "%s/" HOOKS_DIR, home); } if (cfile == NULL) { @@ -391,6 +393,7 @@ void io_save_cal(enum save_display display) if (read_only) return; + run_hook("pre-save"); pthread_mutex_lock(&io_save_mutex); show_bar = 0; @@ -428,6 +431,7 @@ void io_save_cal(enum save_display display) } pthread_mutex_unlock(&io_save_mutex); + run_hook("post-save"); } static void io_load_error(const char *filename, unsigned line, |