diff --git a/src/main.c b/src/main.c index 8d36cd2..6ef0572 100644 --- a/src/main.c +++ b/src/main.c @@ -63,6 +63,7 @@ static void print_usage(char** argv) { printf("--normal-window\t-n\tRender to a normal window\n"); printf("--allow-images\t-i\tAllows images to be rendered\n"); printf("--allow-markup\t-m\tAllows pango markup\n"); + printf("--cache-file\t-k\tSets the cache file to use"); exit(0); } @@ -256,6 +257,12 @@ int main(int argc, char** argv) { .flag = NULL, .val = 'm' }, + { + .name = "cache-file", + .has_arg = required_argument, + .flag = NULL, + .val = 'k' + }, { .name = NULL, .has_arg = 0, @@ -276,8 +283,9 @@ int main(int argc, char** argv) { char* normal_window = NULL; char* allow_images = NULL; char* allow_markup = NULL; + char* cache_file = NULL; char opt; - while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nim", opts, NULL)) != -1) { + while((opt = getopt_long(argc, argv, "hfc:s:C:dS:W:H:p:x:y:nimk:", opts, NULL)) != -1) { switch(opt) { case 'h': print_usage(argv); @@ -329,6 +337,9 @@ int main(int argc, char** argv) { case 'm': allow_markup = "true"; break; + case 'k': + cache_file = optarg; + break; } } @@ -428,6 +439,9 @@ int main(int argc, char** argv) { if(allow_markup != NULL) { map_put(config, "allow_markup", allow_markup); } + if(cache_file != NULL) { + map_put(config, "cache_file", cache_file); + } gtk_init(&argc, &argv); diff --git a/src/wofi.c b/src/wofi.c index 823955d..c232416 100644 --- a/src/wofi.c +++ b/src/wofi.c @@ -27,6 +27,7 @@ static time_t filter_time; static int64_t filter_rate; static bool allow_images, allow_markup; static uint64_t image_size; +static char* cache_file = NULL; struct node { char* text, *action; @@ -150,6 +151,9 @@ static gboolean insert_widget(gpointer data) { } static char* get_cache_path(char* mode) { + if(cache_file != NULL) { + return cache_file; + } char* cache_path = getenv("XDG_CACHE_HOME"); if(cache_path == NULL) { cache_path = utils_concat(3, getenv("HOME"), "/.cache/wofi-", mode); @@ -494,6 +498,7 @@ void wofi_init(struct map* config) { allow_images = strcmp(config_get(config, "allow_images", "false"), "true") == 0; allow_markup = strcmp(config_get(config, "allow_markup", "false"), "true") == 0; image_size = strtol(config_get(config, "image_size", "32"), NULL, 10); + cache_file = map_get(config, "cache_file"); window = gtk_window_new(GTK_WINDOW_TOPLEVEL); gtk_widget_realize(window);