diff --git a/docs/example.Xresources b/docs/example.Xresources index 0f8da58..70566dc 100644 --- a/docs/example.Xresources +++ b/docs/example.Xresources @@ -64,7 +64,7 @@ spmenu.imagewidth: 86 spmenu.imageheight: 86 spmenu.imagegaps: 0 spmenu.imageposition: 0 -spmenu.generatecache: 0 +spmenu.generatecache: 1 spmenu.mode: 0 spmenu.fast: 0 spmenu.hidematchcount: 0 diff --git a/libs/img.c b/libs/img.c index 5266e8d..33fb8d6 100644 --- a/libs/img.c +++ b/libs/img.c @@ -190,7 +190,7 @@ loadimagecache(const char *file, int *width, int *height) } /* try find image from cache first */ - if(!(xdg_cache = getenv("XDG_CACHE_HOME"))) { + if(!(xdg_cache = getenv("XDG_CACHE_HOME")) && generatecache) { if(!(home = getenv("HOME")) && (pw = getpwuid(getuid()))) home = pw->pw_dir; if(!home) { @@ -221,9 +221,9 @@ loadimagecache(const char *file, int *width, int *height) sprintf(&md5[i*2], "%02x", (unsigned int)digest[i]); /* path for cached thumbnail */ - if (xdg_cache) + if (xdg_cache && generatecache) slen = snprintf(NULL, 0, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5)+1; - else + else if (generatecache) slen = snprintf(NULL, 0, "%s/.thumbnails/%s/%s.png", home, dsize, md5)+1; if(!(buf = malloc(slen))) { @@ -231,12 +231,12 @@ loadimagecache(const char *file, int *width, int *height) return; } - if (xdg_cache) + if (xdg_cache && generatecache) sprintf(buf, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5); - else + else if (generatecache) sprintf(buf, "%s/.thumbnails/%s/%s.png", home, dsize, md5); - loadimage(buf, width, height); + if (generatecache) loadimage(buf, width, height); if (image && *width < imagewidth && *height < imageheight) { imlib_free_image(); diff --git a/libs/img.h b/libs/img.h index 47f97e0..d6b8ff5 100644 --- a/libs/img.h +++ b/libs/img.h @@ -8,6 +8,7 @@ static void cleanupimage(void); static void drawimage(void); static void rotateimage(void); static void flipimage(void); +static void loadimage(const char *file, int *width, int *height); static void loadimagecache(const char *file, int *width, int *height); static void resizetoimageheight(int imageheight); diff --git a/options.h b/options.h index 7d47edc..3d15d5d 100644 --- a/options.h +++ b/options.h @@ -22,7 +22,7 @@ static int imagewidth = 86; /* Default image width */ static int imageheight = 86; /* Default image height */ static int imagegaps = 0; /* Image gaps */ static int imageposition = 0; /* Image position (0: Top, 1: Bottom, 2: Center, 3: Top center) */ -static int generatecache = 0; /* Generate image cache by default */ +static int generatecache = 1; /* Generate image cache by default */ /* Mode options */ static int mode = 0; /* Mode to start speedwm in (0: Normal mode, 1: Insert mode) */