kbd_mode: support Disabled mode (K_OFF)
PATCH 1/1 kbd_mode: support Disabled mode (K_OFF)
From: Tianhao Wang <[email protected]>
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/[email protected]/
Signed-off-by Tianhao Wang <[email protected]>
--- src/kbd_mode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
src/kbd_mode.c +10 -0
@@ -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_NORETURNusage (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" )); }
Signature · 1 line
2.48.1
Alexey Gladkov
AppliedQuoted 8 lines · On Mon, Feb 03, 2025 at 06:47:31PM +0100, [email protected] wrote:
From: Tianhao Wang <[email protected]>
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/ttyReference: https://lore.kernel.org/all/[email protected]/
Signed-off-by Tianhao Wang <[email protected]>
Applied. Thanks.
Quoted 39 lines
--- src/kbd_mode.c | 10 ++++++++++ 1 file changed, 10 insertions(+)src/kbd_mode.c +10
-0@@ -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_NORETURNusage (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" )); }Signature · 1 line
2.48.1
Signature · 1 line
Rgrds, legion