aboutsummaryrefslogtreecommitdiffstats
path: root/src/config-ini.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@operamail.com>2014-03-11 17:57:30 +0100
committerMattias Andrée <maandree@operamail.com>2014-03-11 17:57:30 +0100
commitf5a7d6e3931aa248de271e481b21b1275ec3084c (patch)
tree72613821d66fa9a276afd86091e1feb2da355cdc /src/config-ini.c
parentOutcomment .gitignore line that erroneously blocks the src/redshift-gtk dir (diff)
downloadredshift-ng-f5a7d6e3931aa248de271e481b21b1275ec3084c.tar.gz
redshift-ng-f5a7d6e3931aa248de271e481b21b1275ec3084c.tar.bz2
redshift-ng-f5a7d6e3931aa248de271e481b21b1275ec3084c.tar.xz
If even HOME is missing look up the user's home directory from passwd
Signed-off-by: Mattias Andrée <maandree@operamail.com>
Diffstat (limited to 'src/config-ini.c')
-rw-r--r--src/config-ini.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/config-ini.c b/src/config-ini.c
index 4541a0f..3183ba1 100644
--- a/src/config-ini.c
+++ b/src/config-ini.c
@@ -22,6 +22,10 @@
#include <stdlib.h>
#include <string.h>
#include <errno.h>
+#ifndef _WIN32
+# include <pwd.h>
+# include <unistd.h>
+#endif
#include "config-ini.h"
@@ -59,6 +63,14 @@ open_config_file(const char *filepath)
snprintf(cp, sizeof(cp),
"%s/.config/redshift.conf", env);
filepath = cp;
+#ifndef _WIN32
+ } else {
+ struct passwd *pwd = getpwuid(getuid());
+ char *home = pwd->pw_dir;
+ snprintf(cp, sizeof(cp),
+ "%s/.config/redshift.conf", home);
+ filepath = cp;
+#endif
}
if (filepath != NULL) {