--- a/Makefile +++ b/Makefile @@ -185,4 +185,5 @@ ifeq ($(UNAME_S), Linux) + LIBS += -ldl CFLAGS += -fPIE -fstack-clash-protection CXXFLAGS += -fPIE -fstack-clash-protection LDFLAGS += -pie -Wl,-z,relro -Wl,-z,now -fPIE --- a/src/sys/discord_rpc.c +++ b/src/sys/discord_rpc.c @@ -8,6 +8,7 @@ #include "discord_rpc.h" #include "common/appstate.h" #include +#include #include #include #include --- a/src/utils/k_log.c +++ b/src/utils/k_log.c @@ -63,7 +63,17 @@ return path; #else +#if GLIB_CHECK_VERSION(2, 72, 0) const char *state_dir = g_get_user_state_dir(); +#else + const char *state_dir = g_getenv("XDG_STATE_HOME"); + g_autofree gchar *fallback_state_dir = NULL; + if (!state_dir || !g_path_is_absolute(state_dir)) { + fallback_state_dir = g_build_filename(g_get_home_dir(), + ".local", "state", NULL); + state_dir = fallback_state_dir; + } +#endif size_t dir_len = snprintf(NULL, 0, "%s/kew/logs", state_dir); char *dir = malloc(dir_len + 1);