summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authorMichael Pavone <pavone@retrodev.com>2017-03-21 19:56:50 -0700
committerMichael Pavone <pavone@retrodev.com>2017-03-21 19:56:50 -0700
commita435c3b1135d56802fa2c4f17ff498f37cde98d7 (patch)
tree37996cfff4c6e4b4db86843ad01a62bc6ffe5667 /io.c
parent4adb4b1013e6fbd057fe6158a911e7b860a78075 (diff)
Allow variables in screenshot_path like initial_path
Diffstat (limited to 'io.c')
-rw-r--r--io.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/io.c b/io.c
index 0e3571c..d60a587 100644
--- a/io.c
+++ b/io.c
@@ -496,8 +496,12 @@ void handle_binding_up(keybinding * binding)
case UI_SCREENSHOT: {
char *screenshot_base = tern_find_path(config, "ui\0screenshot_path\0").ptrval;
if (!screenshot_base) {
- screenshot_base = get_home_dir();
+ screenshot_base = "$HOME";
}
+ tern_node *vars = tern_insert_ptr(NULL, "HOME", get_home_dir());
+ vars = tern_insert_ptr(vars, "EXEDIR", get_exe_dir());
+ screenshot_base = replace_vars(screenshot_base, vars, 1);
+ tern_free(vars);
time_t now = time(NULL);
struct tm local_store;
char fname_part[256];
@@ -508,6 +512,7 @@ void handle_binding_up(keybinding * binding)
strftime(fname_part, sizeof(fname_part), template, localtime_r(&now, &local_store));
char const *parts[] = {screenshot_base, PATH_SEP, fname_part};
char *path = alloc_concat_m(3, parts);
+ free(screenshot_base);
render_save_screenshot(path);
break;
}