diff options
-rwxr-xr-x | src/Makefile | 2 | ||||
-rw-r--r-- | src/file.c | 29 |
2 files changed, 28 insertions, 3 deletions
diff --git a/src/Makefile b/src/Makefile index 9ab27ed..cf0b5fe 100755 --- a/src/Makefile +++ b/src/Makefile @@ -14,7 +14,7 @@ MANDIR = $(prefix)/share/man/man1 # This is where the history file go HISTORY_DIR= .cache # This is where the config file go -CONFIG_DIR= .config +CONFIG_DIR= .config/sc-im # Change these to your liking or use `make CC=gcc` etc #CC = cc @@ -135,7 +135,15 @@ void loadrc(void) { char rcpath[PATHLEN]; char * home; - if ((home = getenv("HOME"))) { + if ((home = getenv("XDG_CONFIG_HOME"))) { + char config_dir[PATHLEN]; + sprintf(config_dir, "%s/sc-im", home); + mkdir(config_dir,0777); + sprintf(rcpath, "%s/%s", config_dir, CONFIG_FILE); + (void) readfile(rcpath, 0); + } + /* Default to compile time if XDG_CONFIG_HOME not found */ + else if ((home = getenv("HOME"))) { char config_dir[PATHLEN]; sprintf(config_dir, "%s/%s", home,CONFIG_DIR); mkdir(config_dir,0777); @@ -1527,8 +1535,25 @@ int plugin_exists(char * name, int len, char * path) { return 1; } } + /* Check XDG_CONFIG_HOME */ + if ((HomeDir = getenv("XDG_CONFIG_HOME"))) { + sprintf((char *) path, "%s/sc-im/%s", HomeDir, name); + if ((fp = fopen((char *) path, "r"))) { + fclose(fp); + return 1; + } + } + /* Check compile time path (default ~/.config/sc-im) */ + if ((HomeDir = getenv("HOME"))) { + sprintf((char *) path, "%s/%s/%s", HomeDir, CONFIG_DIR, name); + if ((fp = fopen((char *) path, "r"))) { + fclose(fp); + return 1; + } + } + /* LEGACY PATH */ if ((HomeDir = getenv("HOME"))) { - sprintf((char *) path, "%s/%s/%s/%s", HomeDir, CONFIG_DIR, "sc-im", name); + sprintf((char *) path, "%s/.scim/%s", HomeDir, name); if ((fp = fopen((char *) path, "r"))) { fclose(fp); return 1; |