Skip to content

Commit 81b83f1

Browse files
committed
linux: store configuration in $XDG_DATA_HOME
Store configuration in $XDG_DATA_HOME. If unavailable, default to $HOME/.local/share .
1 parent 38dbcde commit 81b83f1

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/os/core/linux/os_core_linux.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1573,8 +1573,17 @@ main(int argc, char **argv)
15731573

15741574
// rjf: grab home directory
15751575
{
1576-
char *home = getenv("HOME");
1577-
info->user_program_data_path = str8_cstring(home);
1576+
char *data_home = getenv("XDG_DATA_HOME");
1577+
if (data_home == 0 ||
1578+
cstring8_length((U8 *)data_home) == 0) {
1579+
// default to $HOME/.local/share (https://specifications.freedesktop.org/basedir/latest/#variables)
1580+
data_home = getenv("HOME");
1581+
info->user_program_data_path = push_str8f(os_lnx_state.arena, "%S/%S",
1582+
str8_cstring(data_home),
1583+
str8_lit(".local/share"));
1584+
} else {
1585+
info->user_program_data_path = str8_cstring(data_home);
1586+
}
15781587
}
15791588

15801589
scratch_end(scratch);

0 commit comments

Comments
 (0)