Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions src/config-ini.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,15 @@ open_config_file(const char *filepath)

if (f == NULL && (env = getenv("XDG_CONFIG_HOME")) != NULL &&
env[0] != '\0') {
snprintf(cp, sizeof(cp), "%s/redshift.conf", env);
snprintf(cp, sizeof(cp),
"%s/redshift/redshift.conf", env);
f = fopen(cp, "r");
if (f == NULL) {
/* Fall back to formerly used path. */
snprintf(cp, sizeof(cp),
"%s/redshift.conf", env);
f = fopen(cp, "r");
}
}

#ifdef _WIN32
Expand All @@ -78,17 +85,29 @@ open_config_file(const char *filepath)
if (f == NULL && (env = getenv("HOME")) != NULL &&
env[0] != '\0') {
snprintf(cp, sizeof(cp),
"%s/.config/redshift.conf", env);
"%s/.config/redshift/redshift.conf", env);
f = fopen(cp, "r");
if (f == NULL) {
/* Fall back to formerly used path. */
snprintf(cp, sizeof(cp),
"%s/.config/redshift.conf", env);
f = fopen(cp, "r");
}
}
#ifndef _WIN32

if (f == NULL) {
struct passwd *pwd = getpwuid(getuid());
char *home = pwd->pw_dir;
snprintf(cp, sizeof(cp),
"%s/.config/redshift.conf", home);
"%s/.config/redshift/redshift.conf", home);
f = fopen(cp, "r");
if (f == NULL) {
/* Fall back to formerly used path. */
snprintf(cp, sizeof(cp),
"%s/.config/redshift.conf", home);
f = fopen(cp, "r");
}
}

if (f == NULL && (env = getenv("XDG_CONFIG_DIRS")) != NULL &&
Expand All @@ -101,9 +120,14 @@ open_config_file(const char *filepath)
int len = end - begin;
if (len > 0) {
snprintf(cp, sizeof(cp),
"%.*s/redshift.conf", len, begin);

"%.*s/redshift/redshift.conf", len, begin);
f = fopen(cp, "r");
if (f != NULL) {
/* Fall back to formerly used path. */
snprintf(cp, sizeof(cp),
"%.*s/redshift.conf", len, begin);
f = fopen(cp, "r");
}
if (f != NULL) break;
}

Expand Down