general: detect in a better way whether we're running on a Linux console
Suggested-by: Mike Frysinger <vapier@gentoo.org>master
parent
ddbff6dcb2
commit
919df09ffa
|
@ -26,7 +26,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
#ifndef NANO_TINY
|
#if defined(__linux__) || !defined(NANO_TINY)
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_UTF8
|
#ifdef ENABLE_UTF8
|
||||||
|
@ -38,6 +38,9 @@
|
||||||
#include <termios.h>
|
#include <termios.h>
|
||||||
#endif
|
#endif
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#ifdef __linux__
|
||||||
|
#include <sys/vt.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_MOUSE
|
#ifdef ENABLE_MOUSE
|
||||||
static int oldinterval = -1;
|
static int oldinterval = -1;
|
||||||
|
@ -1988,8 +1991,10 @@ int main(int argc, char **argv)
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __linux__
|
#ifdef __linux__
|
||||||
|
struct vt_stat dummy;
|
||||||
|
|
||||||
/* Check whether we're running on a Linux console. */
|
/* Check whether we're running on a Linux console. */
|
||||||
console = (getenv("DISPLAY") == NULL);
|
console = (ioctl(0, VT_GETSTATE, &dummy) == 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Back up the terminal settings so that they can be restored. */
|
/* Back up the terminal settings so that they can be restored. */
|
||||||
|
|
Loading…
Reference in New Issue