2011-08-26 16:11:36 +02:00
|
|
|
From 07f0fb4424105c0e90e2add79efe48109b6c9fd1 Mon Sep 17 00:00:00 2001
|
2011-08-23 18:14:51 +02:00
|
|
|
From: Frederic Crozat <fcrozat@suse.com>
|
|
|
|
Date: Thu, 18 Aug 2011 18:28:01 +0200
|
|
|
|
Subject: [PATCH] handle disable_caplock and compose_table and kbd_rate
|
|
|
|
|
|
|
|
---
|
2011-08-26 16:11:36 +02:00
|
|
|
src/vconsole-setup.c | 124 ++++++++++++++++++++++++++++++++++++++++++++++++-
|
|
|
|
1 files changed, 121 insertions(+), 3 deletions(-)
|
2011-08-23 18:14:51 +02:00
|
|
|
|
|
|
|
diff --git a/src/vconsole-setup.c b/src/vconsole-setup.c
|
2011-08-26 16:11:36 +02:00
|
|
|
index 4347a20..af558ef 100644
|
2011-08-23 18:14:51 +02:00
|
|
|
--- a/src/vconsole-setup.c
|
|
|
|
+++ b/src/vconsole-setup.c
|
|
|
|
@@ -39,6 +39,7 @@
|
|
|
|
#include "util.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "macro.h"
|
|
|
|
+#include "strv.h"
|
|
|
|
|
|
|
|
static bool is_vconsole(int fd) {
|
|
|
|
unsigned char data[1];
|
|
|
|
@@ -78,8 +79,8 @@ static int disable_utf8(int fd) {
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, pid_t *_pid) {
|
|
|
|
- const char *args[8];
|
2011-08-26 16:11:36 +02:00
|
|
|
+static int load_keymap(const char *vc, const char *map, const char *map_toggle, bool utf8, bool disable_capslock, pid_t *_pid) {
|
|
|
|
+ const char *args[9];
|
2011-08-23 18:14:51 +02:00
|
|
|
int i = 0;
|
|
|
|
pid_t pid;
|
|
|
|
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -98,6 +99,8 @@ static int load_keymap(const char *vc, const char *map, const char *map_toggle,
|
2011-08-23 18:14:51 +02:00
|
|
|
args[i++] = map;
|
|
|
|
if (map_toggle)
|
|
|
|
args[i++] = map_toggle;
|
|
|
|
+ if (disable_capslock)
|
|
|
|
+ args[i++] = "disable.capslock";
|
|
|
|
args[i++] = NULL;
|
|
|
|
|
|
|
|
if ((pid = fork()) < 0) {
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -149,6 +152,96 @@ static int load_font(const char *vc, const char *font, const char *map, const ch
|
2011-08-23 18:14:51 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+#ifdef TARGET_SUSE
|
2011-08-26 16:11:36 +02:00
|
|
|
+static int load_compose_table(const char *vc, const char *compose_table, pid_t *_pid) {
|
|
|
|
+ const char *args[1024];
|
|
|
|
+ int i = 0;
|
|
|
|
+ pid_t pid;
|
|
|
|
+ char **strv_compose_table = NULL;
|
|
|
|
+
|
|
|
|
+ if (isempty(compose_table)) {
|
|
|
|
+ /* An empty map means no compose table*/
|
|
|
|
+ *_pid = 0;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ args[i++] = KBD_LOADKEYS;
|
|
|
|
+ args[i++] = "-q";
|
|
|
|
+ args[i++] = "-C";
|
|
|
|
+ args[i++] = vc;
|
|
|
|
+
|
|
|
|
+ strv_compose_table = strv_split(compose_table, WHITESPACE);
|
|
|
|
+ if (strv_compose_table) {
|
|
|
|
+ bool compose_loaded = false;
|
|
|
|
+ bool compose_clear = false;
|
|
|
|
+ char **name;
|
|
|
|
+ char *arg;
|
|
|
|
+
|
|
|
|
+ STRV_FOREACH (name, strv_compose_table) {
|
|
|
|
+ if (streq(*name,"-c") || streq(*name,"clear")) {
|
|
|
|
+ compose_clear = true;
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ if (!compose_loaded) {
|
|
|
|
+ if (compose_clear)
|
|
|
|
+ args[i++] = "-c";
|
|
|
|
+ }
|
|
|
|
+ asprintf(&arg, "compose.%s",*name);
|
|
|
|
+ compose_loaded = true;
|
|
|
|
+ args[i++] = arg;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ strv_free(strv_compose_table);
|
|
|
|
+ }
|
|
|
|
+ args[i++] = NULL;
|
|
|
|
+
|
|
|
|
+ if ((pid = fork()) < 0) {
|
|
|
|
+ log_error("Failed to fork: %m");
|
|
|
|
+ return -errno;
|
|
|
|
+ } else if (pid == 0) {
|
|
|
|
+ execv(args[0], (char **) args);
|
|
|
|
+ _exit(EXIT_FAILURE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ *_pid = pid;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+
|
2011-08-23 18:14:51 +02:00
|
|
|
+static int set_kbd_rate(const char *vc, const char *kbd_rate, const char *kbd_delay, pid_t *_pid) {
|
|
|
|
+ const char *args[7];
|
|
|
|
+ int i = 0;
|
|
|
|
+ pid_t pid;
|
|
|
|
+
|
|
|
|
+ if (isempty(kbd_rate) && isempty(kbd_delay)) {
|
|
|
|
+ *_pid = 0;
|
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ args[i++] = "/bin/kbdrate";
|
|
|
|
+ if (!isempty(kbd_rate)) {
|
|
|
|
+ args[i++] = "-r";
|
|
|
|
+ args[i++] = kbd_rate;
|
|
|
|
+ }
|
|
|
|
+ if (!isempty(kbd_delay)) {
|
|
|
|
+ args[i++] = "-d";
|
|
|
|
+ args[i++] = kbd_delay;
|
|
|
|
+ }
|
|
|
|
+ args[i++] = "-s";
|
|
|
|
+ args[i++] = NULL;
|
|
|
|
+
|
|
|
|
+ if ((pid = fork()) < 0) {
|
|
|
|
+ log_error("Failed to fork: %m");
|
|
|
|
+ return -errno;
|
|
|
|
+ } else if (pid == 0) {
|
|
|
|
+ execv(args[0], (char **) args);
|
|
|
|
+ _exit(EXIT_FAILURE);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ *_pid = pid;
|
|
|
|
+ return 0;
|
|
|
|
+}
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
const char *vc;
|
|
|
|
char *vc_keymap = NULL;
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -162,8 +255,16 @@ int main(int argc, char **argv) {
|
2011-08-23 18:14:51 +02:00
|
|
|
#ifdef TARGET_MANDRIVA
|
|
|
|
char *vc_keytable = NULL;
|
|
|
|
#endif
|
|
|
|
+#ifdef TARGET_SUSE
|
|
|
|
+ char *vc_kbd_delay = NULL;
|
|
|
|
+ char *vc_kbd_rate = NULL;
|
|
|
|
+ char *vc_kbd_disable_caps_lock = NULL;
|
2011-08-26 16:11:36 +02:00
|
|
|
+ char *vc_compose_table = NULL;
|
|
|
|
+ pid_t kbd_rate_pid = 0, compose_table_pid = 0;
|
2011-08-23 18:14:51 +02:00
|
|
|
+#endif
|
|
|
|
int fd = -1;
|
|
|
|
bool utf8;
|
|
|
|
+ bool disable_capslock = false;
|
|
|
|
int r = EXIT_FAILURE;
|
|
|
|
pid_t font_pid = 0, keymap_pid = 0;
|
|
|
|
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -268,6 +369,10 @@ int main(int argc, char **argv) {
|
2011-08-23 18:14:51 +02:00
|
|
|
#elif defined(TARGET_SUSE)
|
|
|
|
if ((r = parse_env_file("/etc/sysconfig/keyboard", NEWLINE,
|
|
|
|
"KEYTABLE", &vc_keymap,
|
|
|
|
+ "KBD_DELAY", &vc_kbd_delay,
|
|
|
|
+ "KBD_RATE", &vc_kbd_rate,
|
|
|
|
+ "KBD_DISABLE_CAPS_LOCK", &vc_kbd_disable_caps_lock,
|
|
|
|
+ "COMPOSETABLE", &vc_compose_table,
|
|
|
|
NULL)) < 0) {
|
|
|
|
|
|
|
|
if (r != -ENOENT)
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -283,6 +388,7 @@ int main(int argc, char **argv) {
|
2011-08-23 18:14:51 +02:00
|
|
|
if (r != -ENOENT)
|
|
|
|
log_warning("Failed to read /etc/sysconfig/console: %s", strerror(-r));
|
|
|
|
}
|
|
|
|
+ disable_capslock = strcasecmp(vc_kbd_disable_caps_lock, "YES") == 0;
|
|
|
|
|
|
|
|
#elif defined(TARGET_ARCH)
|
|
|
|
if ((r = parse_env_file("/etc/rc.conf", NEWLINE,
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -439,7 +545,11 @@ int main(int argc, char **argv) {
|
2011-08-23 18:14:51 +02:00
|
|
|
if (!utf8)
|
|
|
|
disable_utf8(fd);
|
|
|
|
|
|
|
|
- if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, &keymap_pid) >= 0 &&
|
2011-08-26 16:11:36 +02:00
|
|
|
+ if (load_keymap(vc, vc_keymap, vc_keymap_toggle, utf8, disable_capslock, &keymap_pid) >= 0 &&
|
2011-08-23 18:14:51 +02:00
|
|
|
+#ifdef TARGET_SUSE
|
2011-08-26 16:11:36 +02:00
|
|
|
+ load_compose_table(vc, vc_compose_table, &compose_table_pid) >= 0 &&
|
2011-08-23 18:14:51 +02:00
|
|
|
+ set_kbd_rate(vc, vc_kbd_rate, vc_kbd_delay, &kbd_rate_pid) >= 0 &&
|
|
|
|
+#endif
|
|
|
|
load_font(vc, vc_font, vc_font_map, vc_font_unimap, &font_pid) >= 0)
|
|
|
|
r = EXIT_SUCCESS;
|
|
|
|
|
2011-08-26 16:11:36 +02:00
|
|
|
@@ -447,6 +557,14 @@ finish:
|
2011-08-23 18:14:51 +02:00
|
|
|
if (keymap_pid > 0)
|
|
|
|
wait_for_terminate_and_warn(KBD_LOADKEYS, keymap_pid);
|
|
|
|
|
|
|
|
+#ifdef TARGET_SUSE
|
2011-08-26 16:11:36 +02:00
|
|
|
+ if (compose_table_pid > 0)
|
|
|
|
+ wait_for_terminate_and_warn(KBD_LOADKEYS, compose_table_pid);
|
|
|
|
+
|
2011-08-23 18:14:51 +02:00
|
|
|
+ if (kbd_rate_pid > 0)
|
|
|
|
+ wait_for_terminate_and_warn("/bin/kbdrate", kbd_rate_pid);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
if (font_pid > 0)
|
|
|
|
wait_for_terminate_and_warn(KBD_SETFONT, font_pid);
|
|
|
|
|
|
|
|
--
|
|
|
|
1.7.3.4
|
|
|
|
|