pty: add "colorterm" property
The colorterm property is used (if set) as COLORTERM environment variable. Note that this variable (despite the name) is not used with terminfo/termcap. Instead, it's solely used to identify the running terminal. Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
parent
eba5178643
commit
d50f80a72f
25
src/pty.c
25
src/pty.c
@ -60,6 +60,7 @@ struct kmscon_pty {
|
||||
void *data;
|
||||
|
||||
char *term;
|
||||
char *colorterm;
|
||||
char **argv;
|
||||
char *seat;
|
||||
};
|
||||
@ -119,6 +120,7 @@ void kmscon_pty_unref(struct kmscon_pty *pty)
|
||||
kmscon_pty_close(pty);
|
||||
free(pty->seat);
|
||||
free(pty->argv);
|
||||
free(pty->colorterm);
|
||||
free(pty->term);
|
||||
shl_ring_free(pty->msgbuf);
|
||||
ev_eloop_unref(pty->eloop);
|
||||
@ -141,6 +143,22 @@ int kmscon_pty_set_term(struct kmscon_pty *pty, const char *term)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kmscon_pty_set_colorterm(struct kmscon_pty *pty, const char *colorterm)
|
||||
{
|
||||
char *t;
|
||||
|
||||
if (!pty || !colorterm)
|
||||
return -EINVAL;
|
||||
|
||||
t = strdup(colorterm);
|
||||
if (!t)
|
||||
return -ENOMEM;
|
||||
free(pty->colorterm);
|
||||
pty->colorterm = t;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int kmscon_pty_set_argv(struct kmscon_pty *pty, char **argv)
|
||||
{
|
||||
char **t;
|
||||
@ -196,7 +214,8 @@ static bool pty_is_open(struct kmscon_pty *pty)
|
||||
}
|
||||
|
||||
static void __attribute__((noreturn))
|
||||
exec_child(const char *term, char **argv, const char *seat)
|
||||
exec_child(const char *term, const char *colorterm, char **argv,
|
||||
const char *seat)
|
||||
{
|
||||
if (!term)
|
||||
term = "vt220";
|
||||
@ -204,6 +223,8 @@ exec_child(const char *term, char **argv, const char *seat)
|
||||
argv = (char*[]){ "/bin/login", NULL };
|
||||
|
||||
setenv("TERM", term, 1);
|
||||
if (colorterm)
|
||||
setenv("COLORTERM", colorterm, 1);
|
||||
if (seat)
|
||||
setenv("XDG_SEAT", seat, 1);
|
||||
execvp(argv[0], argv);
|
||||
@ -322,7 +343,7 @@ static int pty_spawn(struct kmscon_pty *pty, int master,
|
||||
return -errno;
|
||||
case 0:
|
||||
setup_child(master, &ws);
|
||||
exec_child(pty->term, pty->argv, pty->seat);
|
||||
exec_child(pty->term, pty->colorterm, pty->argv, pty->seat);
|
||||
exit(EXIT_FAILURE);
|
||||
default:
|
||||
log_debug("forking child %d", pid);
|
||||
|
@ -54,6 +54,7 @@ int kmscon_pty_new(struct kmscon_pty **out, kmscon_pty_input_cb input_cb,
|
||||
void kmscon_pty_ref(struct kmscon_pty *pty);
|
||||
void kmscon_pty_unref(struct kmscon_pty *pty);
|
||||
int kmscon_pty_set_term(struct kmscon_pty *pty, const char *term);
|
||||
int kmscon_pty_set_colorterm(struct kmscon_pty *pty, const char *colorterm);
|
||||
int kmscon_pty_set_argv(struct kmscon_pty *pty, char **argv);
|
||||
int kmscon_pty_set_seat(struct kmscon_pty *pty, const char *seat);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user