2013-06-14 16:48:02 +02:00
|
|
|
Set NumLock according to /etc/sysconfig/keyboard.
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2013-06-14 16:48:02 +02:00
|
|
|
https://bugzilla.novell.com/show_bug.cgi?id=746595
|
2013-04-23 11:39:56 +02:00
|
|
|
|
2013-06-14 16:48:02 +02:00
|
|
|
Authors:
|
|
|
|
Stanislav Brabec <sbrabec@suse.cz>
|
|
|
|
Cristian Rodríguez <crrodriguez@opensuse.org>
|
|
|
|
|
2015-03-27 09:39:40 +01:00
|
|
|
---
|
|
|
|
Makefile.am | 13 ++++++++++
|
|
|
|
rules/73-seat-numlock.rules | 8 ++++++
|
|
|
|
src/login/numlock-on.c | 34 +++++++++++++++++++++++++++
|
|
|
|
src/vconsole/vconsole-setup.c | 40 ++++++++++++++++++++++++++++++--
|
|
|
|
units/systemd-vconsole-setup.service.in | 2 -
|
|
|
|
5 files changed, 94 insertions(+), 3 deletions(-)
|
|
|
|
|
2015-09-27 14:32:31 +02:00
|
|
|
--- systemd-222.orig/Makefile.am
|
|
|
|
+++ systemd-222/Makefile.am
|
|
|
|
@@ -3805,6 +3805,19 @@ dist_udevrules_DATA += \
|
|
|
|
rules/60-persistent-v4l.rules
|
2013-06-14 16:48:02 +02:00
|
|
|
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
+numlock_on_SOURCES = \
|
|
|
|
+ src/login/numlock-on.c
|
|
|
|
+
|
|
|
|
+numlock_on_CFLAGS = \
|
|
|
|
+ $(AM_CFLAGS)
|
|
|
|
+
|
|
|
|
+udevlibexec_PROGRAMS += \
|
|
|
|
+ numlock-on
|
|
|
|
+
|
|
|
|
+dist_udevrules_DATA += \
|
|
|
|
+ rules/73-seat-numlock.rules
|
|
|
|
+
|
|
|
|
+# ------------------------------------------------------------------------------
|
2015-09-27 14:32:31 +02:00
|
|
|
mtd_probe_SOURCES = \
|
|
|
|
src/udev/mtd_probe/mtd_probe.c \
|
|
|
|
src/udev/mtd_probe/mtd_probe.h \
|
2013-06-14 16:48:02 +02:00
|
|
|
--- /dev/null
|
2015-09-27 14:32:31 +02:00
|
|
|
+++ systemd-222/rules/73-seat-numlock.rules
|
2013-06-14 16:48:02 +02:00
|
|
|
@@ -0,0 +1,8 @@
|
|
|
|
+# This file is part of SUSE customization of systemd.
|
|
|
|
+#
|
|
|
|
+# systemd is free software; you can redistribute it and/or modify it
|
|
|
|
+# under the terms of the GNU General Public License as published by
|
|
|
|
+# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+# (at your option) any later version.
|
|
|
|
+
|
|
|
|
+SUBSYSTEM=="tty", ACTION=="add", KERNEL=="tty[0-9]|tty1[0-2]", TEST=="/run/numlock-on", RUN+="numlock-on $env{DEVNAME}"
|
|
|
|
--- /dev/null
|
2015-09-27 14:32:31 +02:00
|
|
|
+++ systemd-222/src/login/numlock-on.c
|
2013-06-14 16:48:02 +02:00
|
|
|
@@ -0,0 +1,34 @@
|
|
|
|
+/*
|
|
|
|
+ * numlock-on.c: Turn numlock-on
|
|
|
|
+ *
|
|
|
|
+ * This file may be freely copied under the terms of the GNU General
|
|
|
|
+ * Public License (GPL), version 2, or at your option any later
|
|
|
|
+ * version.
|
|
|
|
+
|
|
|
|
+ * Copyright (C) 2013 Stanislav Brabec, SUSE
|
|
|
|
+ *
|
|
|
|
+ * based on setleds.c, which is
|
|
|
|
+ * Copyright (C) 1994-1999 Andries E. Brouwer
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <sys/ioctl.h>
|
|
|
|
+#include <linux/kd.h>
|
|
|
|
+
|
|
|
|
+int
|
|
|
|
+main(int argc, char **argv) {
|
|
|
|
+ char flags;
|
|
|
|
+
|
|
|
|
+ if (ioctl(0, KDGKBLED, &flags)) {
|
|
|
|
+ perror("KDGKBLED");
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (ioctl(0, KDSKBLED, flags | LED_NUM | (LED_NUM << 4))) {
|
|
|
|
+ perror("KDSKBLED");
|
|
|
|
+ exit(1);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ exit(0);
|
|
|
|
+}
|
2015-09-27 14:32:31 +02:00
|
|
|
--- systemd-222.orig/src/vconsole/vconsole-setup.c
|
|
|
|
+++ systemd-222/src/vconsole/vconsole-setup.c
|
|
|
|
@@ -41,6 +41,10 @@
|
|
|
|
#include "terminal-util.h"
|
|
|
|
#include "signal-util.h"
|
2015-03-27 09:39:40 +01:00
|
|
|
|
|
|
|
+#define BIOS_DATA_AREA 0x400
|
|
|
|
+#define BDA_KEYBOARD_STATUS_FLAGS_4 0x97
|
|
|
|
+#define BDA_KSF4_NUMLOCK_MASK 0x02
|
|
|
|
+
|
|
|
|
static bool is_vconsole(int fd) {
|
|
|
|
unsigned char data[1];
|
|
|
|
|
2015-09-27 14:32:31 +02:00
|
|
|
@@ -359,9 +363,10 @@ int main(int argc, char **argv) {
|
2015-03-27 09:39:40 +01:00
|
|
|
#ifdef HAVE_SYSV_COMPAT
|
|
|
|
_cleanup_free_ char
|
|
|
|
*vc_kbd_delay = NULL, *vc_kbd_rate = NULL,
|
|
|
|
- *vc_kbd_disable_caps_lock = NULL, *vc_compose_table = NULL;
|
|
|
|
+ *vc_kbd_disable_caps_lock = NULL, *vc_compose_table = NULL,
|
|
|
|
+ *vc_kbd_numlock = NULL;
|
|
|
|
#endif
|
|
|
|
- bool disable_capslock = false;
|
|
|
|
+ bool disable_capslock = false, numlock = false;
|
2015-09-27 14:32:31 +02:00
|
|
|
bool comp_ok, rate_ok;
|
2015-03-27 09:39:40 +01:00
|
|
|
_cleanup_close_ int fd = -1;
|
2015-09-27 14:32:31 +02:00
|
|
|
bool utf8, font_copy = false, font_ok, keyboard_ok;
|
|
|
|
@@ -399,6 +404,7 @@ int main(int argc, char **argv) {
|
2015-03-27 09:39:40 +01:00
|
|
|
"KBD_DELAY", &vc_kbd_delay,
|
|
|
|
"KBD_RATE", &vc_kbd_rate,
|
|
|
|
"KBD_DISABLE_CAPS_LOCK", &vc_kbd_disable_caps_lock,
|
|
|
|
+ "KBD_NUMLOCK", &vc_kbd_numlock,
|
|
|
|
"COMPOSETABLE", &vc_compose_table,
|
|
|
|
NULL);
|
|
|
|
if (r < 0 && r != -ENOENT)
|
2015-09-27 14:32:31 +02:00
|
|
|
@@ -416,6 +422,32 @@ int main(int argc, char **argv) {
|
2015-03-27 09:39:40 +01:00
|
|
|
|
2015-09-27 14:32:31 +02:00
|
|
|
disable_capslock = vc_kbd_disable_caps_lock &&
|
|
|
|
strcasecmp(vc_kbd_disable_caps_lock, "YES") == 0;
|
|
|
|
+ numlock = vc_kbd_numlock && strcaseeq(vc_kbd_numlock, "yes");
|
2015-03-27 09:39:40 +01:00
|
|
|
+#if defined(__i386__) || defined(__x86_64__)
|
2015-09-27 14:32:31 +02:00
|
|
|
+ if (vc_kbd_numlock && strcaseeq(vc_kbd_numlock, "bios")) {
|
|
|
|
+ int _cleanup_close_ fdmem;
|
|
|
|
+ char c;
|
|
|
|
+
|
|
|
|
+ fdmem = open ("/dev/mem", O_RDONLY);
|
|
|
|
+ if (fdmem < 0) {
|
|
|
|
+ log_error("Failed to open /dev/mem: %m");
|
|
|
|
+ return EXIT_FAILURE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (lseek(fdmem, BIOS_DATA_AREA + BDA_KEYBOARD_STATUS_FLAGS_4, SEEK_SET) == (off_t) -1) {
|
|
|
|
+ log_error("Failed to seek /dev/mem: %m");
|
|
|
|
+ return EXIT_FAILURE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (read(fdmem, &c, sizeof(char)) == -1) {
|
|
|
|
+ log_error("Failed to read /dev/mem: %m");
|
|
|
|
+ return EXIT_FAILURE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (c & BDA_KSF4_NUMLOCK_MASK)
|
|
|
|
+ numlock = true;
|
|
|
|
+ }
|
|
|
|
+#endif /* x86 */
|
|
|
|
#endif /* HAVE_SYSV_COMPAT */
|
2015-03-27 09:39:40 +01:00
|
|
|
|
|
|
|
r = parse_env_file("/etc/vconsole.conf", NEWLINE,
|
2015-09-27 14:32:31 +02:00
|
|
|
@@ -451,6 +483,10 @@ int main(int argc, char **argv) {
|
|
|
|
font_ok = font_load_and_wait(vc, vc_font, vc_font_map, vc_font_unimap) > 0;
|
|
|
|
keyboard_ok = keyboard_load_and_wait(vc, vc_keymap, vc_keymap_toggle,
|
|
|
|
utf8, disable_capslock) > 0;
|
2015-03-27 09:39:40 +01:00
|
|
|
+ if (numlock)
|
|
|
|
+ touch("/run/numlock-on");
|
|
|
|
+ else
|
|
|
|
+ unlink("/run/numlock-on");
|
|
|
|
#ifdef HAVE_SYSV_COMPAT
|
2015-09-27 14:32:31 +02:00
|
|
|
comp_ok = compose_load_and_wait(vc, vc_compose_table);
|
|
|
|
rate_ok = kbdrate_set_and_wait(vc, vc_kbd_rate, vc_kbd_delay);
|
|
|
|
--- systemd-222.orig/units/systemd-vconsole-setup.service.in
|
|
|
|
+++ systemd-222/units/systemd-vconsole-setup.service.in
|
2015-03-27 09:39:40 +01:00
|
|
|
@@ -10,7 +10,7 @@ Description=Setup Virtual Console
|
|
|
|
Documentation=man:systemd-vconsole-setup.service(8) man:vconsole.conf(5)
|
2012-07-23 10:41:36 +02:00
|
|
|
DefaultDependencies=no
|
|
|
|
Conflicts=shutdown.target
|
|
|
|
-Before=sysinit.target shutdown.target
|
2013-01-29 07:05:16 +01:00
|
|
|
+Before=sysinit.target shutdown.target systemd-udev-trigger.service
|
2012-11-02 17:30:32 +01:00
|
|
|
ConditionPathExists=/dev/tty0
|
2012-07-23 10:41:36 +02:00
|
|
|
|
|
|
|
[Service]
|