diff --git a/src/conf.c b/src/conf.c index c203f81..057fdd7 100644 --- a/src/conf.c +++ b/src/conf.c @@ -57,11 +57,13 @@ static void print_help() "\t --silent Suppress notices and warnings\n" "\t-s, --switchvt Automatically switch to VT\n" "\n" - "Login Process Options:\n" + "Terminal Options:\n" "\t-l, --login Start the given login process instead\n" "\t of the default process; all following\n" "\t arguments are passed as argv to this\n" "\t process\n" + "\t-t, --term Value of the TERM environment variable\n" + "\t for the child process\n" "\n" "Input Device Options:\n" "\t --xkb-layout Set XkbLayout for input devices\n" @@ -73,7 +75,7 @@ static void print_help() int conf_parse_argv(int argc, char **argv) { int show_help = 0; - char short_options[] = ":hvsl:"; + char short_options[] = ":hvsl:t:"; struct option long_options[] = { { "help", no_argument, NULL, 'h' }, { "verbose", no_argument, NULL, 'v' }, @@ -84,6 +86,7 @@ int conf_parse_argv(int argc, char **argv) { "xkb-variant", required_argument, NULL, -2 }, { "xkb-options", required_argument, NULL, -3 }, { "login", required_argument, NULL, 'l' }, + { "term", required_argument, NULL, 't' }, { NULL, 0, NULL, 0 }, }; int idx; @@ -123,6 +126,9 @@ int conf_parse_argv(int argc, char **argv) conf_global.login = optarg; --optind; goto done; + case 't': + conf_global.term = optarg; + break; case ':': fprintf(stderr, "Missing argument for option -%c\n", optopt); @@ -158,6 +164,9 @@ done: if (!conf_global.xkb_options) conf_global.xkb_options = ""; + if (!conf_global.term) + conf_global.term = "linux"; + if (show_help) { print_help(); conf_global.exit = 1; diff --git a/src/conf.h b/src/conf.h index ed69845..b57fb9a 100644 --- a/src/conf.h +++ b/src/conf.h @@ -59,6 +59,8 @@ struct conf_obj { const char *xkb_variant; const char *xkb_options; + /* TERM value */ + const char *term; /* login process */ char *login; /* argv for login process */ diff --git a/src/pty.c b/src/pty.c index a596d78..87aab1b 100644 --- a/src/pty.c +++ b/src/pty.c @@ -110,16 +110,10 @@ void kmscon_pty_unref(struct kmscon_pty *pty) free(pty); } -/* - * TODO: - * - Decide which terminal we're emulating and set TERM accordingly. - * - Decide what to exec here: login, some getty equivalent, a shell... - * - Might also need to update some details in utmp wtmp and friends. - */ static void __attribute__((noreturn)) exec_child(int pty_master) { - setenv("TERM", "linux", 1); + setenv("TERM", conf_global.term, 1); execvp(conf_global.login, conf_global.argv); log_err("failed to exec child: %m");