summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2019-12-01 20:21:46 -0500
committerJune McEnroe <june@causal.agency>2019-12-01 20:21:46 -0500
commit0414263ca5e2ef787df03b14b1a9748b350f3012 (patch)
tree93e9c65f11038ddb1f556b0663194abdbc51c1e0
parentImplement database file search (diff)
downloadlitterbox-0414263ca5e2ef787df03b14b1a9748b350f3012.tar.gz
litterbox-0414263ca5e2ef787df03b14b1a9748b350f3012.zip
Add XDG_DATA_DIRS default value
-rw-r--r--litterbox.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/litterbox.h b/litterbox.h
index 48d707c..07d4bbc 100644
--- a/litterbox.h
+++ b/litterbox.h
@@ -48,15 +48,19 @@ static inline sqlite3 *dbOpen(int flags) {
 	const char *home = getenv("HOME");
 	const char *dataHome = getenv("XDG_DATA_HOME");
 	const char *dataDirs = getenv("XDG_DATA_DIRS");
+
 	char path[PATH_MAX];
 	if (dataHome) {
 		snprintf(path, sizeof(path), "%s/" DATABASE_PATH, dataHome);
 	} else {
+		if (!home) errx(EX_CONFIG, "HOME unset");
 		snprintf(path, sizeof(path), "%s/.local/share/" DATABASE_PATH, home);
 	}
 	sqlite3 *db = dbOpenPath(path, flags);
 	if (db) return db;
-	while (dataDirs && *dataDirs) {
+
+	if (!dataDirs) dataDirs = "/usr/local/share:/usr/share";
+	while (*dataDirs) {
 		size_t len = strcspn(dataDirs, ":");
 		snprintf(path, sizeof(path), "%.*s/" DATABASE_PATH, (int)len, dataDirs);
 		db = dbOpenPath(path, flags);
an title='2020-09-11 20:46:34 -0400'>2020-09-11Add debian VM name to sshJune McEnroe 2020-09-11Add influencer tweetJune McEnroe 2020-09-10Add The Kingdom of GodsJune McEnroe Reading has really slowed down :( 2020-09-07Add SunglassesJune McEnroe An IRC find. 2020-09-06Add Between the BreathsJune McEnroe One of those good songs from a soundtrack of a film that probably isn't? The summary sounds a lot more interesting than the title implies, at least. 2020-09-04Open /dev/tty in nudgeJune McEnroe This makes it work even when it's run connected to a pipe, i.e. as the notify command of catgirl... 2020-09-04Add nudgeJune McEnroe 2020-09-03Build fbclock with -lzJune McEnroe I guess this got lost somewhere, long ago... 2020-08-29Add tweets from retweetsJune McEnroe