diff --git a/src/common.h b/src/common.h index 6431bf44..88e9b1f4 100644 --- a/src/common.h +++ b/src/common.h @@ -55,9 +55,11 @@ int g_input_add(GIOChannel *source, int condition, int g_input_add_full(GIOChannel *source, int priority, int condition, GInputFunction function, void *data); -/* return full path for ~/.irssi */ +/* return if xdg is being used */ +int is_xdg_supported(); +/* return full path for irssi folder */ const char *get_irssi_dir(void); -/* return full path for ~/.irssi/config */ +/* return full path for irssi config */ const char *get_irssi_config(void); /* max. size for %d */ diff --git a/src/core/core.c b/src/core/core.c index 13f67f20..5c6a98de 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -81,7 +81,7 @@ int is_xdg_supported() const char *get_irssi_dir(void) { - return (xdg_support = 1) ? irssi_xdg_dir : irssi_dir; + return irssi_dir; } /* return full path for ~/.irssi/config */ diff --git a/src/fe-common/core/fe-common-core.c b/src/fe-common/core/fe-common-core.c index c7cdd995..b5ce8b6b 100644 --- a/src/fe-common/core/fe-common-core.c +++ b/src/fe-common/core/fe-common-core.c @@ -408,7 +408,7 @@ static void autorun_startup(void) GString *buf; gsize tpos; - /* open ~/.irssi/startup and run all commands in it */ + /* open $CONFIG/startup and run all commands in it */ path = g_strdup_printf("%s/startup", get_irssi_dir()); handle = g_io_channel_new_file(path, "r", NULL); g_free(path); diff --git a/src/fe-common/core/themes.c b/src/fe-common/core/themes.c index ff737c41..e5f11008 100644 --- a/src/fe-common/core/themes.c +++ b/src/fe-common/core/themes.c @@ -932,7 +932,11 @@ THEME_REC *theme_load(const char *setname) theme = theme_find(name); /* check home dir */ - fname = g_strdup_printf("%s/%s.theme", get_irssi_dir(), name); + if (is_xdg_supported()) + fname = g_build_filename(g_get_user_data_dir(), "irssi", + g_strdup_printf("%s.theme", name), NULL); + else + fname = g_strdup_printf("%s/%s.theme", get_irssi_dir(), name); if (stat(fname, &statbuf) != 0) { /* check global config dir */ g_free(fname); @@ -1256,8 +1260,11 @@ static void theme_save(THEME_REC *theme, int save_all) g_hash_table_foreach(theme->modules, (GHFunc) module_save, &data); basename = g_path_get_basename(theme->path); - /* always save the theme to ~/.irssi/ */ - path = g_strdup_printf("%s/%s", get_irssi_dir(), basename); + /* always save the theme */ + if (is_xdg_supported()) + path = g_build_filename(g_get_user_data_dir(), "irssi", basename, NULL); + else + path = g_strdup_printf("%s/%s", get_irssi_dir(), basename); ok = config_write(config, path, 0660) == 0; g_free(basename); @@ -1413,7 +1420,10 @@ void themes_reload(void) /* first there's default theme.. */ current_theme = theme_load("default"); if (current_theme == NULL) { - fname = g_strdup_printf("%s/default.theme", get_irssi_dir()); + if (is_xdg_supported()) + fname = g_build_filename(g_get_user_data_dir(), "irssi", "default.theme"); + else + fname = g_strdup_printf("%s/default.theme", get_irssi_dir()); current_theme = theme_create(fname, "default"); current_theme->default_color = -1; theme_read(current_theme, NULL);