mirror of
https://github.com/irssi/irssi.git
synced 2026-08-22 01:52:19 +02:00
add: xdg-support
- config file XDG support inspired from #511 - added support to try loading scripts from XDG_DATA_HOME, if not present try loading from XDG_CONFIG_HOME, if not present try loading the usual way.
This commit is contained in:
parent
a1cbb8d28f
commit
f972d05025
3 changed files with 45 additions and 15 deletions
|
|
@ -390,6 +390,34 @@ char *perl_script_get_path(const char *name)
|
|||
file = IS_PERL_SCRIPT(name) ? g_strdup(name) :
|
||||
g_strdup_printf("%s.pl", name);
|
||||
|
||||
/* check from %XDG_DATA_HOME% */
|
||||
path = g_build_filename(g_get_user_data_dir(), "irssi/scripts/", file, NULL);
|
||||
if (stat(path, &statbuf) != 0) {
|
||||
g_free(path);
|
||||
path = g_strdup_printf(SCRIPTDIR"/%s", file);
|
||||
if (stat(path, &statbuf) != 0) {
|
||||
g_free(path);
|
||||
path = NULL;
|
||||
} else {
|
||||
g_free(file);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/* check from %XDG_CONFIG_HOME% */
|
||||
path = g_build_filename(g_get_user_config_dir(), "irssi/scripts/", file, NULL);
|
||||
if (stat(path, &statbuf) != 0) {
|
||||
g_free(path);
|
||||
path = g_strdup_printf(SCRIPTDIR"/%s", file);
|
||||
if (stat(path, &statbuf) != 0) {
|
||||
g_free(path);
|
||||
path = NULL;
|
||||
} else {
|
||||
g_free(file);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
/* check from ~/.irssi/scripts/ */
|
||||
path = g_strdup_printf("%s/scripts/%s", get_irssi_dir(), file);
|
||||
if (stat(path, &statbuf) != 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue