# HG changeset patch # User Michael Pavone # Date 1490151410 25200 # Node ID a719e2c98b54c1af5378f505df190b1745f4d661 # Parent 72ea3885e7b5a9bc6676f7f4e4279df5b79d5d2c Allow variables in screenshot_path like initial_path diff -r 72ea3885e7b5 -r a719e2c98b54 default.cfg --- a/default.cfg Tue Mar 21 19:48:08 2017 -0700 +++ b/default.cfg Tue Mar 21 19:56:50 2017 -0700 @@ -200,7 +200,8 @@ #starting path for ROM browsing, accepts special variables $HOME, $EXEDIR #and variables defined in the OS environment initial_path $HOME - #screenshot_path defaults to the user's home/profile directory if not specified + #path for storing internal screenshots, accepts the same variables as initial_path + screenshot_path $HOME #see strftime for the format specifiers valid in screenshot_template screenshot_template blastem_%c.ppm } diff -r 72ea3885e7b5 -r a719e2c98b54 io.c --- a/io.c Tue Mar 21 19:48:08 2017 -0700 +++ b/io.c Tue Mar 21 19:56:50 2017 -0700 @@ -496,8 +496,12 @@ 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 @@ 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; }