mirror of
https://github.com/pikami/st.git
synced 2024-11-25 21:35:42 +00:00
Add support for utmp in st
St runs an interactive shell and not a login shell, and it means that profile is not loaded. The default terminal configuration in some system is not the correct for st, but since profile is not loaded there is no way of getting a script configures the correct values. St doesn't update the utmp files, this is the job of another suckless tool, utmp. Utmp also opens a login shell (it is the logical behaviour when you create a new user record) it is a good option execute utmp and then get a correct input in utmp, wtmp and lastlog file, and execute the content of the profile.
This commit is contained in:
parent
0392d165d0
commit
5afb3862ba
@ -8,6 +8,7 @@
|
|||||||
static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";
|
static char font[] = "Liberation Mono:pixelsize=12:antialias=false:autohint=false";
|
||||||
static int borderpx = 2;
|
static int borderpx = 2;
|
||||||
static char shell[] = "/bin/sh";
|
static char shell[] = "/bin/sh";
|
||||||
|
static char *utmp = NULL;
|
||||||
|
|
||||||
/* identification sequence returned in DA and DECID */
|
/* identification sequence returned in DA and DECID */
|
||||||
static char vtiden[] = "\033[?6c";
|
static char vtiden[] = "\033[?6c";
|
||||||
|
17
st.c
17
st.c
@ -1153,16 +1153,22 @@ execsh(void) {
|
|||||||
else
|
else
|
||||||
die("who are you?\n");
|
die("who are you?\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (utmp)
|
||||||
|
sh = utmp;
|
||||||
|
else if (pw->pw_shell[0])
|
||||||
|
sh = pw->pw_shell;
|
||||||
|
else
|
||||||
|
sh = shell;
|
||||||
|
args = (opt_cmd) ? opt_cmd : (char *[]){sh, NULL};
|
||||||
|
snprintf(buf, sizeof(buf), "%lu", xw.win);
|
||||||
|
|
||||||
unsetenv("COLUMNS");
|
unsetenv("COLUMNS");
|
||||||
unsetenv("LINES");
|
unsetenv("LINES");
|
||||||
unsetenv("TERMCAP");
|
unsetenv("TERMCAP");
|
||||||
|
|
||||||
sh = (pw->pw_shell[0]) ? pw->pw_shell : shell;
|
|
||||||
snprintf(buf, sizeof(buf), "%lu", xw.win);
|
|
||||||
|
|
||||||
setenv("LOGNAME", pw->pw_name, 1);
|
setenv("LOGNAME", pw->pw_name, 1);
|
||||||
setenv("USER", pw->pw_name, 1);
|
setenv("USER", pw->pw_name, 1);
|
||||||
setenv("SHELL", sh, 1);
|
setenv("SHELL", args[0], 1);
|
||||||
setenv("HOME", pw->pw_dir, 1);
|
setenv("HOME", pw->pw_dir, 1);
|
||||||
setenv("TERM", termname, 1);
|
setenv("TERM", termname, 1);
|
||||||
setenv("WINDOWID", buf, 1);
|
setenv("WINDOWID", buf, 1);
|
||||||
@ -1174,7 +1180,6 @@ execsh(void) {
|
|||||||
signal(SIGTERM, SIG_DFL);
|
signal(SIGTERM, SIG_DFL);
|
||||||
signal(SIGALRM, SIG_DFL);
|
signal(SIGALRM, SIG_DFL);
|
||||||
|
|
||||||
args = opt_cmd ? opt_cmd : (char *[]){sh, "-i", NULL};
|
|
||||||
execvp(args[0], args);
|
execvp(args[0], args);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user