generate cache by default, don't load cache if we're not also generating cache

This commit is contained in:
speedie 2023-03-06 20:20:19 +01:00
parent 563806f2d1
commit 5ae0fc4eea
4 changed files with 9 additions and 8 deletions

View file

@ -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

View file

@ -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();

View file

@ -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);

View file

@ -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) */