Преглед на файлове

Merge pull request #59 from chrboe/xdg-cache-dir

Respect XDG_CACHE_HOME
Joachim Nilsson преди 5 години
родител
ревизия
08bb6f2703
No account linked to committer's email
променени са 1 файла, в които са добавени 8 реда и са изтрити 3 реда
  1. 8
    3
      src/light.c

+ 8
- 3
src/light.c Целия файл

@@ -303,10 +303,15 @@ bool light_initialize(int argc, char **argv)
303 303
 	int rc;
304 304
 
305 305
 	/* Classic SUID root mode or new user based cache files */
306
-	if (geteuid() == 0)
306
+	if (geteuid() == 0) {
307 307
 		snprintf(ctx.prefix, sizeof(ctx.prefix), "%s", "/etc/light");
308
-	else
309
-		snprintf(ctx.prefix, sizeof(ctx.prefix), "%s/.cache/light", getenv("HOME"));
308
+	} else {
309
+		char *xdg_cache = getenv("XDG_CACHE_HOME");
310
+		if (xdg_cache != NULL)
311
+			snprintf(ctx.prefix, sizeof(ctx.prefix), "%s/light", xdg_cache);
312
+		else
313
+			snprintf(ctx.prefix, sizeof(ctx.prefix), "%s/.cache/light", getenv("HOME"));
314
+	}
310 315
 
311 316
 	light_defaults();
312 317
 	if (!light_parse_args(argc, argv)) {