public inbox for kbd@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] kbd_mode: support Disabled mode (K_OFF)
@ 2025-02-03 17:47 shrik3
  2025-02-04 13:13 ` Alexey Gladkov
  0 siblings, 1 reply; 2+ messages in thread
From: shrik3 @ 2025-02-03 17:47 UTC (permalink / raw)
  To: kbd; +Cc: Tianhao Wang

From: Tianhao Wang <shrik3@mailbox.org>

Since linux 2.6.39 KDGKBMODE could have K_OFF (0x04), the Disabled mode.
This may be set by e.g. Xorg that doesn't read /dev/tty

Reference: https://lore.kernel.org/all/AANLkTikZe1EuvNQHceNUdKFpmmeAbQG8H+34AG9fw43u@mail.gmail.com/

Signed-off-by: Tianhao Wang <shrik3@mailbox.org>
---
 src/kbd_mode.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/src/kbd_mode.c b/src/kbd_mode.c
index 9a4aff3..f37c321 100644
--- a/src/kbd_mode.c
+++ b/src/kbd_mode.c
@@ -16,9 +16,14 @@
 #include <sysexits.h>
 #include <sys/ioctl.h>
 #include <linux/kd.h>
+#include <linux/version.h>
 
 #include "libcommon.h"
 
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
+#define HAS_K_OFF
+#endif
+
 static void KBD_ATTR_NORETURN
 usage(int rc, const struct kbd_help *options)
 {
@@ -48,6 +53,11 @@ fprint_mode(FILE *stream, int  mode)
 		case K_UNICODE:
 			fprintf(stream, _("The keyboard is in Unicode (UTF-8) mode"));
 			break;
+#ifdef HAS_K_OFF
+		case K_OFF:
+			fprintf(stream, _("The keyboard is in Disabled mode, perhaps you are using a graphical environment?"));
+			break;
+#endif
 		default:
 			fprintf(stream, _("The keyboard is in some unknown mode"));
 	}
-- 
2.48.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-02-04 13:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-03 17:47 [PATCH] kbd_mode: support Disabled mode (K_OFF) shrik3
2025-02-04 13:13 ` Alexey Gladkov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox