commit ad198dd55b1c9faa5ac4e28548b3c99aec5c7218
parent d50987538ff11a13a72f1f06d1538d99b46f9ee1
Author: Michael Forney <mforney@mforney.org>
Date: Sun, 30 Aug 2015 01:21:32 -0700
launch: Always use a new VT when DISPLAY or WAYLAND_DISPLAY is set
Diffstat:
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/launch/launch.c b/launch/launch.c
@@ -305,12 +305,11 @@ done:
static void
find_vt(char *vt, size_t size)
{
- char *vt_num_string;
+ char *vtnr;
- if ((vt_num_string = getenv("XDG_VTNR"))) {
- if (snprintf(vt, size, "/dev/tty%s", vt_num_string) >= size)
- die("XDG_VTNR is too long");
- } else {
+ /* If we are running from an existing X or wayland session, always open a new
+ * VT instead of using the current one. */
+ if (getenv("DISPLAY") || getenv("WAYLAND_DISPLAY") || !(vtnr = getenv("XDG_VTNR"))) {
int tty0_fd, vt_num;
tty0_fd = open("/dev/tty0", O_RDWR);
@@ -321,6 +320,9 @@ find_vt(char *vt, size_t size)
close(tty0_fd);
if (snprintf(vt, size, "/dev/tty%d", vt_num) >= size)
die("VT number is too large");
+ } else {
+ if (snprintf(vt, size, "/dev/tty%s", vtnr) >= size)
+ die("XDG_VTNR is too long");
}
}