Skip to content

Commit

Permalink
Follow the XDG specification.
Browse files Browse the repository at this point in the history
We're still 100% backward-compatible.
  • Loading branch information
LemonBoy committed Jul 9, 2016
1 parent b8f7eaa commit 4e2f33b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
2 changes: 0 additions & 2 deletions src/common.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef __COMMON_H
#define __COMMON_H

#define IRSSI_DIR_FULL "%s/.irssi" /* %s == g_get_home_dir() */

#define IRSSI_GLOBAL_CONFIG "irssi.conf" /* config file name in /etc/ */
#define IRSSI_HOME_CONFIG "config" /* config file name in ~/.irssi/ */

Expand Down
20 changes: 13 additions & 7 deletions src/core/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,21 @@ void core_register_options(void)

void core_preinit(const char *path)
{
const char *home;
char *str;
int len;

if (irssi_dir == NULL) {
home = g_get_home_dir();
if (home == NULL)
home = ".";

irssi_dir = g_strdup_printf(IRSSI_DIR_FULL, home);
/* Try the ~/.irssi folder first, for backward-compatibility
* reasons, then try the XDG one and stick to the latter if
* both this is the first time the user boots irssi */
const char *home = g_get_home_dir();
irssi_dir = g_build_filename(home? home: ".", ".irssi", NULL);

if (g_file_test(irssi_dir, G_FILE_TEST_IS_DIR) == FALSE) {
g_free(irssi_dir);
irssi_dir = g_build_filename(g_get_user_config_dir(),
"irssi", NULL);
}
} else {
str = irssi_dir;
irssi_dir = fix_path(str);
Expand All @@ -200,8 +205,9 @@ void core_preinit(const char *path)
if (irssi_dir[len-1] == G_DIR_SEPARATOR)
irssi_dir[len-1] = '\0';
}

if (irssi_config_file == NULL)
irssi_config_file = g_strdup_printf("%s/"IRSSI_HOME_CONFIG, irssi_dir);
irssi_config_file = g_build_filename(irssi_dir, IRSSI_HOME_CONFIG, NULL);
else {
str = irssi_config_file;
irssi_config_file = fix_path(str);
Expand Down

0 comments on commit 4e2f33b

Please sign in to comment.