tApplying the patch of Roberto Caballero to set WINDOWID and all the pwuid() - … | |
git clone git://src.adamsgaard.dk/st | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 6d4e525ed95fbddc38be441394a02dc9233b157d | |
parent 35421371ca150b6bd0fd1330e7b30a99029dbce1 | |
Author: Christoph Lohmann <[email protected]> | |
Date: Sun, 28 Oct 2012 06:54:08 +0100 | |
Applying the patch of Roberto Caballero to set WINDOWID and all the pwuid() | |
variables. Thanks! xinit() and ttynew() had to be switched in their | |
call-appearance. Otherwise xw.win is not set. | |
Diffstat: | |
M st.c | 15 ++++++++++++++- | |
1 file changed, 14 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/st.c b/st.c | |
t@@ -5,6 +5,7 @@ | |
#include <fcntl.h> | |
#include <limits.h> | |
#include <locale.h> | |
+#include <pwd.h> | |
#include <stdarg.h> | |
#include <stdbool.h> | |
#include <stdio.h> | |
t@@ -881,11 +882,23 @@ void | |
execsh(void) { | |
char **args; | |
char *envshell = getenv("SHELL"); | |
+ const struct passwd *pass = getpwuid(getuid()); | |
+ char buf[sizeof(long) * 8 + 1]; | |
unsetenv("COLUMNS"); | |
unsetenv("LINES"); | |
unsetenv("TERMCAP"); | |
+ if(pass) { | |
+ setenv("LOGNAME", pass->pw_name, 1); | |
+ setenv("USER", pass->pw_name, 1); | |
+ setenv("SHELL", pass->pw_shell, 0); | |
+ setenv("HOME", pass->pw_dir, 0); | |
+ } | |
+ | |
+ snprintf(buf, sizeof(buf), "%lu", xw.win); | |
+ setenv("WINDOWID", buf, 1); | |
+ | |
signal(SIGCHLD, SIG_DFL); | |
signal(SIGHUP, SIG_DFL); | |
signal(SIGINT, SIG_DFL); | |
t@@ -2795,8 +2808,8 @@ main(int argc, char *argv[]) { | |
run: | |
setlocale(LC_CTYPE, ""); | |
tnew(80, 24); | |
- ttynew(); | |
xinit(); | |
+ ttynew(); | |
selinit(); | |
run(); | |
return 0; |