mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-03-18 05:34:02 -04:00
config: prefer $SHELL over /etc/passwd
If the user hasn't configured a shell in footrc, use $SHELL. Only if that variable isn't set do we use the shell from /etc/passwd.
This commit is contained in:
parent
f235bfdfdf
commit
74175b5bd1
3 changed files with 15 additions and 10 deletions
16
config.c
16
config.c
|
|
@ -44,15 +44,19 @@ static const uint32_t default_bright[] = {
|
||||||
static char *
|
static char *
|
||||||
get_shell(void)
|
get_shell(void)
|
||||||
{
|
{
|
||||||
struct passwd *passwd = getpwuid(getuid());
|
const char *shell = getenv("SHELL");
|
||||||
if (passwd == NULL) {
|
|
||||||
LOG_ERRNO("failed to lookup user");
|
if (shell == NULL) {
|
||||||
return NULL;
|
struct passwd *passwd = getpwuid(getuid());
|
||||||
|
if (passwd == NULL) {
|
||||||
|
LOG_ERRNO("failed to lookup user");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
shell = passwd->pw_shell;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *shell = passwd->pw_shell;
|
|
||||||
LOG_DBG("user's shell: %s", shell);
|
LOG_DBG("user's shell: %s", shell);
|
||||||
|
|
||||||
return strdup(shell);
|
return strdup(shell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -41,9 +41,10 @@ in this order:
|
||||||
_XxY_ (-padding).
|
_XxY_ (-padding).
|
||||||
|
|
||||||
*shell*
|
*shell*
|
||||||
Executable to launch. Typically a shell. Default: the user's
|
Executable to launch. Typically a shell. Default: _$SHELL_ if set,
|
||||||
default shell (as specified in _/etc/passwd_). You can also pass
|
otherwise the user's default shell (as specified in
|
||||||
arguments. For example "/bin/bash --norc".
|
_/etc/passwd_). You can also pass arguments. For example
|
||||||
|
"/bin/bash --norc".
|
||||||
|
|
||||||
*login-shell*
|
*login-shell*
|
||||||
Start a login shell, by prepending a '-' to argv[0]. Default: _no_.
|
Start a login shell, by prepending a '-' to argv[0]. Default: _no_.
|
||||||
|
|
|
||||||
2
footrc
2
footrc
|
|
@ -4,7 +4,7 @@
|
||||||
# scrollback=1000
|
# scrollback=1000
|
||||||
# geometry=800x600
|
# geometry=800x600
|
||||||
# pad=2x2
|
# pad=2x2
|
||||||
# shell=<user's default shell (from /etc/passwd)> (you may need to override if you need a login shell)
|
# shell=$SHELL (if set, otherwise user's default shell from /etc/passwd)
|
||||||
# term=foot
|
# term=foot
|
||||||
# login-shell=no
|
# login-shell=no
|
||||||
# workers=<number of logical CPUs>
|
# workers=<number of logical CPUs>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue