main: add --login-shell command line option

This commit is contained in:
Daniel Eklöf 2020-02-20 18:34:23 +01:00
parent ec3c699fde
commit d3071b817e
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

9
main.c
View file

@ -46,6 +46,7 @@ print_usage(const char *prog_name)
" -c,--config=PATH load configuration from PATH (XDG_CONFIG_HOME/footrc)\n"
" -f,--font=FONT comma separated list of fonts in fontconfig format (monospace)\n"
" -t,--term=TERM value to set the environment variable TERM to (foot)\n"
" --login-shell start shell as a login shell\n"
" -g,--geometry=WIDTHxHEIGHT set initial width and height\n"
" -s,--server[=PATH] run as a server (use 'footclient' to start terminals).\n"
" Without PATH, XDG_RUNTIME_DIR/foot.sock will be used.\n"
@ -136,6 +137,7 @@ main(int argc, char *const *argv)
static const struct option longopts[] = {
{"config", required_argument, NULL, 'c'},
{"term", required_argument, NULL, 't'},
{"login-shell", no_argument, NULL, 'L'},
{"font", required_argument, NULL, 'f'},
{"geometry", required_argument, NULL, 'g'},
{"server", optional_argument, NULL, 's'},
@ -151,6 +153,7 @@ main(int argc, char *const *argv)
const char *conf_path = NULL;
const char *conf_term = NULL;
bool login_shell = false;
tll(char *) conf_fonts = tll_init();
int conf_width = -1;
int conf_height = -1;
@ -164,7 +167,7 @@ main(int argc, char *const *argv)
bool log_syslog = true;
while (true) {
int c = getopt_long(argc, argv, "c:t:f:g:s::Pp:l::Svh", longopts, NULL);
int c = getopt_long(argc, argv, "c:t:Lf:g:s::Pp:l::Svh", longopts, NULL);
if (c == -1)
break;
@ -177,6 +180,10 @@ main(int argc, char *const *argv)
conf_term = optarg;
break;
case 'L':
login_shell = true;
break;
case 'f':
tll_free_and_free(conf_fonts, free);
for (char *font = strtok(optarg, ","); font != NULL; font = strtok(NULL, ",")) {