* [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
* Re: [PATCH] kbd_mode: support Disabled mode (K_OFF)
2025-02-03 17:47 [PATCH] kbd_mode: support Disabled mode (K_OFF) shrik3
@ 2025-02-04 13:13 ` Alexey Gladkov
0 siblings, 0 replies; 2+ messages in thread
From: Alexey Gladkov @ 2025-02-04 13:13 UTC (permalink / raw)
To: shrik3; +Cc: kbd
On Mon, Feb 03, 2025 at 06:47:31PM +0100, shrik3@mailbox.org wrote:
> 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>
Applied. Thanks.
> ---
> 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
>
>
--
Rgrds, legion
^ permalink raw reply [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