From 4e6dcf3e37e9aba48ab80f4db3606bcdb46d3032 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Courr=C3=A8ges-Anglas?= Date: Thu, 20 Feb 2014 12:04:30 +0100 Subject: If HOME is not set in the env., fallback to the passwd entry. * No attempt to detect pwd.h / getpwuid, not sure if needed. --- src/main.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main.c b/src/main.c index e2cea15..e5456c6 100644 --- a/src/main.c +++ b/src/main.c @@ -35,6 +35,7 @@ #include #include #include +#include #include "ratpoison.h" @@ -423,8 +424,15 @@ read_startup_files (char *alt_rcfile) homedir = getenv ("HOME"); if (!homedir) { - PRINT_ERROR (("ratpoison: $HOME not set!?\n")); + struct passwd *pw; + + pw = getpwuid (getuid ()); + if (pw) + homedir = pw->pw_dir; } + + if (!homedir) + PRINT_ERROR (("ratpoison: no home directory!?\n")); else { char *filename; -- cgit v1.2.3