Added the ability to specify the cache file to use
This commit is contained in:
parent
cb2241574d
commit
0a110def8f
16
src/main.c
16
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("--normal-window\t-n\tRender to a normal window\n");
|
||||||
printf("--allow-images\t-i\tAllows images to be rendered\n");
|
printf("--allow-images\t-i\tAllows images to be rendered\n");
|
||||||
printf("--allow-markup\t-m\tAllows pango markup\n");
|
printf("--allow-markup\t-m\tAllows pango markup\n");
|
||||||
|
printf("--cache-file\t-k\tSets the cache file to use");
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +257,12 @@ int main(int argc, char** argv) {
|
|||||||
.flag = NULL,
|
.flag = NULL,
|
||||||
.val = 'm'
|
.val = 'm'
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
.name = "cache-file",
|
||||||
|
.has_arg = required_argument,
|
||||||
|
.flag = NULL,
|
||||||
|
.val = 'k'
|
||||||
|
},
|
||||||
{
|
{
|
||||||
.name = NULL,
|
.name = NULL,
|
||||||
.has_arg = 0,
|
.has_arg = 0,
|
||||||
@ -276,8 +283,9 @@ int main(int argc, char** argv) {
|
|||||||
char* normal_window = NULL;
|
char* normal_window = NULL;
|
||||||
char* allow_images = NULL;
|
char* allow_images = NULL;
|
||||||
char* allow_markup = NULL;
|
char* allow_markup = NULL;
|
||||||
|
char* cache_file = NULL;
|
||||||
char opt;
|
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) {
|
switch(opt) {
|
||||||
case 'h':
|
case 'h':
|
||||||
print_usage(argv);
|
print_usage(argv);
|
||||||
@ -329,6 +337,9 @@ int main(int argc, char** argv) {
|
|||||||
case 'm':
|
case 'm':
|
||||||
allow_markup = "true";
|
allow_markup = "true";
|
||||||
break;
|
break;
|
||||||
|
case 'k':
|
||||||
|
cache_file = optarg;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,6 +439,9 @@ int main(int argc, char** argv) {
|
|||||||
if(allow_markup != NULL) {
|
if(allow_markup != NULL) {
|
||||||
map_put(config, "allow_markup", allow_markup);
|
map_put(config, "allow_markup", allow_markup);
|
||||||
}
|
}
|
||||||
|
if(cache_file != NULL) {
|
||||||
|
map_put(config, "cache_file", cache_file);
|
||||||
|
}
|
||||||
|
|
||||||
gtk_init(&argc, &argv);
|
gtk_init(&argc, &argv);
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ static time_t filter_time;
|
|||||||
static int64_t filter_rate;
|
static int64_t filter_rate;
|
||||||
static bool allow_images, allow_markup;
|
static bool allow_images, allow_markup;
|
||||||
static uint64_t image_size;
|
static uint64_t image_size;
|
||||||
|
static char* cache_file = NULL;
|
||||||
|
|
||||||
struct node {
|
struct node {
|
||||||
char* text, *action;
|
char* text, *action;
|
||||||
@ -150,6 +151,9 @@ static gboolean insert_widget(gpointer data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static char* get_cache_path(char* mode) {
|
static char* get_cache_path(char* mode) {
|
||||||
|
if(cache_file != NULL) {
|
||||||
|
return cache_file;
|
||||||
|
}
|
||||||
char* cache_path = getenv("XDG_CACHE_HOME");
|
char* cache_path = getenv("XDG_CACHE_HOME");
|
||||||
if(cache_path == NULL) {
|
if(cache_path == NULL) {
|
||||||
cache_path = utils_concat(3, getenv("HOME"), "/.cache/wofi-", mode);
|
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_images = strcmp(config_get(config, "allow_images", "false"), "true") == 0;
|
||||||
allow_markup = strcmp(config_get(config, "allow_markup", "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);
|
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);
|
window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
|
||||||
gtk_widget_realize(window);
|
gtk_widget_realize(window);
|
||||||
|
Loading…
Reference in New Issue
Block a user