aboutsummaryrefslogtreecommitdiffstats
path: root/fbcon.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2019-01-31 07:56:42 +0100
committerGerd Hoffmann <kraxel@redhat.com>2019-01-31 07:56:42 +0100
commit7fcf29ed3f77f60873bad160d5afac498746d6d8 (patch)
tree80ce8451b601dbc6a935534d0eac66c0ddb83981 /fbcon.c
parentc49dee052ca9f54c79321644a590b455802f424a (diff)
downloadfbida-7fcf29ed3f77f60873bad160d5afac498746d6d8.tar.gz
read keymap from /etc/vconsole.conf
Diffstat (limited to 'fbcon.c')
-rw-r--r--fbcon.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/fbcon.c b/fbcon.c
index df3ac96..8c738b3 100644
--- a/fbcon.c
+++ b/fbcon.c
@@ -158,6 +158,34 @@ const char *ansiseq[KEY_MAX] = {
[ KEY_F12 ] = "\x1b[24~",
};
+static void xkb_configure(void)
+{
+ char line[128], *m, *v, *h;
+ FILE *fp;
+
+ fp = fopen("/etc/vconsole.conf", "r");
+ if (!fp)
+ return;
+ while (fgets(line, sizeof(line), fp)) {
+ if (strncmp(line, "KEYMAP=", 7) != 0)
+ continue;
+ m = line + 7;
+ if (*m == '"')
+ m++;
+ if ((h = strchr(m, '\n')) != NULL)
+ *h = 0;
+ if ((h = strchr(m, '"')) != NULL)
+ *h = 0;
+ v = strchr(m, '-');
+ if (v) {
+ *(v++) = 0;
+ layout.variant = strdup(v);
+ }
+ layout.layout = strdup(m);
+ }
+ fclose(fp);
+}
+
/* ---------------------------------------------------------------------- */
struct color {
@@ -371,8 +399,17 @@ int main(int argc, char *argv[])
input = libinput_get_fd(kbd);
/* init udev + xkbcommon */
+ xkb_configure();
xkb = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
map = xkb_keymap_new_from_names(xkb, &layout, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ if (!map) {
+ layout.variant = NULL;
+ map = xkb_keymap_new_from_names(xkb, &layout, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ if (!map) {
+ layout.layout = "us";
+ map = xkb_keymap_new_from_names(xkb, &layout, XKB_KEYMAP_COMPILE_NO_FLAGS);
+ }
+ }
state = xkb_state_new(map);
/* init terminal emulation */