aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/kmscon-runtime-keymap-switch.patch
blob: 6692e761bc9937247a2a4149881c076f15401580 (about) (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
Make kmscon listen to a FIFO in /tmp that clients can write to
to request a keymap change.

Patch by Mathieu Othacehe <m.othacehe@gmail.com>.
Modified by Florian Pelz <pelzflorian@pelzflorian.de>
and Ludovic Courtès <ludo@gnu.org>.

diff --git a/src/pty.c b/src/pty.c
index 1443f4a..f64cb5b 100644
--- a/src/pty.c
+++ b/src/pty.c
@@ -46,6 +46,8 @@
 
 #define KMSCON_NREAD 16384
 
+#define INPUT_KEYMAP_UPDATE_FILE "/tmp/kmscon-%d-keymap-update"
+
 struct kmscon_pty {
 	unsigned long ref;
 	struct ev_eloop *eloop;
@@ -241,9 +243,22 @@ static bool pty_is_open(struct kmscon_pty *pty)
 	return pty->fd >= 0;
 }
 
+static int kmscon_keymap_update(pid_t pid)
+{
+	char *file;
+	int ret;
+
+	ret = asprintf(&file, INPUT_KEYMAP_UPDATE_FILE, pid);
+	if (ret < 0)
+		return ret;
+
+	return setenv("KEYMAP_UPDATE", file, 1);
+}
+
 static void __attribute__((noreturn))
 exec_child(const char *term, const char *colorterm, char **argv,
-	   const char *seat, const char *vtnr, bool env_reset)
+	   const char *seat, const char *vtnr, bool env_reset,
+	   pid_t kmscon_pid)
 {
 	char **env;
 	char **def_argv;
@@ -277,6 +292,8 @@ exec_child(const char *term, const char *colorterm, char **argv,
 	if (vtnr)
 		setenv("XDG_VTNR", vtnr, 1);
 
+	kmscon_keymap_update(kmscon_pid);
+
 	execve(argv[0], argv, environ);
 
 	log_err("failed to exec child %s: %m", argv[0]);
@@ -383,12 +400,14 @@ static int pty_spawn(struct kmscon_pty *pty, int master,
 			unsigned short width, unsigned short height)
 {
 	pid_t pid;
+	pid_t kmscon_pid;
 	struct winsize ws;
 
 	memset(&ws, 0, sizeof(ws));
 	ws.ws_col = width;
 	ws.ws_row = height;
 
+	kmscon_pid = getpid();
 	pid = fork();
 	switch (pid) {
 	case -1:
@@ -397,7 +416,7 @@ static int pty_spawn(struct kmscon_pty *pty, int master,
 	case 0:
 		setup_child(master, &ws);
 		exec_child(pty->term, pty->colorterm, pty->argv, pty->seat,
-			   pty->vtnr, pty->env_reset);
+			   pty->vtnr, pty->env_reset, kmscon_pid);
 		exit(EXIT_FAILURE);
 	default:
 		log_debug("forking child %d", pid);
diff --git a/src/uterm_input.c b/src/uterm_input.c
index 6fcbc4b..990a09d 100644
--- a/src/uterm_input.c
+++ b/src/uterm_input.c
@@ -178,6 +178,10 @@ static void input_new_dev(struct uterm_input *input,
 	if (ret)
 		goto err_rcodepoints;
 
+       /* Add the FIFO fd only to the first input poll loop. */
+       if (shl_dlist_empty(&input->devices))
+       	uxkb_dev_keymap_update(dev);
+
 	if (input->awake > 0) {
 		ret = input_wake_up_dev(dev);
 		if (ret)
diff --git a/src/uterm_input_internal.h b/src/uterm_input_internal.h
index 04e6cc9..ec44459 100644
--- a/src/uterm_input_internal.h
+++ b/src/uterm_input_internal.h
@@ -39,6 +39,8 @@
 #include "shl_misc.h"
 #include "uterm_input.h"
 
+#define INPUT_KEYMAP_UPDATE_FILE "/tmp/kmscon-%d-keymap-update"
+
 enum uterm_input_device_capability {
 	UTERM_DEVICE_HAS_KEYS = (1 << 0),
 	UTERM_DEVICE_HAS_LEDS = (1 << 1),
@@ -62,6 +64,8 @@ struct uterm_input_dev {
 
 	bool repeating;
 	struct ev_timer *repeat_timer;
+	struct ev_fd *fd_update;
+	int rupdate_fd;
 };
 
 struct uterm_input {
@@ -95,6 +99,7 @@ void uxkb_desc_destroy(struct uterm_input *input);
 
 int uxkb_dev_init(struct uterm_input_dev *dev);
 void uxkb_dev_destroy(struct uterm_input_dev *dev);
+int uxkb_dev_keymap_update(struct uterm_input_dev *dev);
 int uxkb_dev_process(struct uterm_input_dev *dev,
 		     uint16_t key_state,
 		     uint16_t code);
diff --git a/src/uterm_input_uxkb.c b/src/uterm_input_uxkb.c
index 925c755..8fe08f8 100644
--- a/src/uterm_input_uxkb.c
+++ b/src/uterm_input_uxkb.c
@@ -31,6 +31,9 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
 #include <xkbcommon/xkbcommon.h>
 #include "shl_hook.h"
 #include "shl_llog.h"
@@ -178,6 +181,106 @@ static void timer_event(struct ev_timer *timer, uint64_t num, void *data)
 	shl_hook_call(dev->input->hook, dev->input, &dev->repeat_event);
 }
 
+static void uxkb_keymap_update_handler(struct ev_fd *fd, int mask, void *data)
+{
+	struct uterm_input_dev *dev = data;
+	char in;
+	char keymap[4][255];
+	int pos = 0;
+	int curr_keymap = 0;
+	int ret;
+	char *model, *layout, *variant, *options;
+
+	if (!(mask & EV_READABLE))
+		return;
+
+	memset(keymap, 0, sizeof(keymap));
+
+	model = keymap[0];
+	layout = keymap[1];
+	variant = keymap[2];
+	options = keymap[3];
+
+	do {
+	  ret = read(dev->rupdate_fd, &in, sizeof(in));
+	  if (ret <= 0)
+	    break;
+
+	  keymap[curr_keymap][pos++] = in;
+
+	  if (in == '\0') {
+	    curr_keymap++;
+	    pos = 0;
+	  }
+	} while (1);
+
+	llog_info(dev->input, "HANDLER CALLED %s|%s|%s\n",
+		  model, layout, variant);
+
+	struct uterm_input *input = dev->input;
+	struct shl_dlist *iter;
+
+       /* Apply the new layout to all the inputs. */
+       shl_dlist_for_each(iter, &input->devices) {
+       	struct uterm_input_dev *dev;
+		dev = shl_dlist_entry(iter,
+					struct uterm_input_dev,
+					list);
+	        uxkb_desc_init(dev->input, model, layout, variant, options, NULL);
+               dev->state = xkb_state_new(dev->input->keymap);
+               if (!dev->state) {
+               	llog_error(dev->input, "cannot create XKB state");
+                      	return;
+                }
+       }
+
+	/* The client will now close the FIFO.  Close it too, and re-create a
+	 * FIFO so other clients can eventually connect.  */
+	ev_eloop_rm_fd(fd);
+	close(dev->rupdate_fd);
+	dev->rupdate_fd = -1;
+	uxkb_dev_keymap_update(dev);
+
+}
+
+int uxkb_dev_keymap_update(struct uterm_input_dev *dev)
+{
+	int ret;
+	char *file;
+	int pid = getpid();
+
+	ret = asprintf(&file, INPUT_KEYMAP_UPDATE_FILE, pid);
+	if (ret < 0)
+		return ret;
+
+	(void) unlink(file);
+	ret = mkfifo(file, S_IRWXU);
+	if (ret < 0) {
+		llog_warn(dev->input, "could not open fifo");
+		return -EFAULT;
+	}
+	dev->rupdate_fd = open(file, O_RDONLY | O_NONBLOCK);
+	if (dev->rupdate_fd < 0) {
+		llog_warn(dev->input, "cannot open file %s (%d): %m",
+			  file, errno);
+		return -EFAULT;
+	}
+
+	setenv("KEYMAP_UPDATE", file, 1);
+
+	ret = ev_eloop_new_fd(dev->input->eloop, &dev->fd_update,
+			      dev->rupdate_fd, EV_READABLE,
+			      uxkb_keymap_update_handler, dev);
+	if (ret) {
+		llog_error(dev->input, "could not init keymap update");
+		close(dev->rupdate_fd);
+		dev->rupdate_fd = -1;
+		return ret;
+	}
+
+	return 0;
+}
+
 int uxkb_dev_init(struct uterm_input_dev *dev)
 {
 	int ret;
-name): New procedures. * gnu/system.scm (operating-system-bootcfg): Specify the Btrfs subvolume file name the store resides on to the `operating-system-bootcfg' procedure, using the new BTRFS-SUBVOLUME-FILE-NAME argument. * doc/guix.texi (File Systems): Add a Btrfs subsection to document the use of subvolumes. * gnu/tests/install.scm (%btrfs-root-on-subvolume-os) (%btrfs-root-on-subvolume-os-source) (%btrfs-root-on-subvolume-installation-script) (%test-btrfs-root-on-subvolume-os): New variables. Maxim Cournoyer 2020-05-19gnu: grub: Allow a PNG image and replace "aspect-ratio" with "resolution"....* gnu/bootloaders/grub.scm (<grub-image>): Remove this record and replace it by ... (<grub-theme>)[image]: ... this field with the default from %background-image, (<grub-theme>)[resolution]: ... this field with the defaults from 'width' and 'height' of 'grub-background-image'. (<grub-theme>)[images]: Remove this field. (svg->png): Rename to ... (image->png): ... and use 'copy-file' instead of 'svg->png', if the suffix of the image file is not ".svg". (grub-background-image): Remove the arguments 'width' and 'height'. (grub-theme-image): Add function. (grub-theme-resolution): Add function. (grub-theme-gfxmode): Add function. (grub-image): Remove function. (grub-image?): Remove function. (grub-image-aspect-ratio): Remove function. (grub-image-file): Remove function. (grub-theme-images): Remove function. (%default-theme): Remove variable. (%background-image): Remove variable. Using image formats different to SVG was not possible. For a <grub-image> to be chosen, the 'aspect-ratio' of it had to be 4/3, as the resolution of any image was defaulting to 1024 x 768. There was no code to determine the proper boot-resolution to make any use of a list of images with different aspect-ratios. It seems to be a better solution to only define a single image with any format, and use a given resolution only for the conversion from a SVG file. This also makes the use of a special <grub-image> record unnecessary. Moving the default values from '%background-image' and '%default-theme' into <grub-theme> makes a customisation easier without (inherit) and allows to remove the undocumented variables %background-image' and '%default-theme'. Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Stefan 2020-05-16bootloader: grub: Refer to the native 'grub-mklayout' and font file....* gnu/bootloader/grub.scm (eye-candy): Refer to the native FONT-FILE. (keyboard-layout-file): Refer to the native 'grub-mklayout'. Ludovic Courtès 2020-04-23Merge branch 'master' into core-updates... Conflicts: etc/news.scm gnu/local.mk gnu/packages/bootloaders.scm gnu/packages/linphone.scm gnu/packages/linux.scm gnu/packages/tls.scm gnu/system.scm Marius Bakke 2020-04-20gnu: Add u-boot-pinebook-pro-rk3399....* gnu/packages/bootloaders (u-boot-pinebook-pro-rk3399): New variable. * gnu/packages/patches/u-boot-DT-for-Pinebook-Pro.patch: New file. * gnu/packages/patches/u-boot-add-boe-nv140fhmn49-display.patch: New file. * gnu/packages/patches/u-boot-gpio-keys-binding-cons.patch: New file. * gnu/packages/patches/u-boot-leds-common-binding-con.patch: New file. * gnu/packages/patches/u-boot-support-Pinebook-Pro-laptop.patch: New file. * gnu/packages/patches/u-boot-video-rockchip-fix-build.patch: New file. * gnu/local.mk (dist_patch_DATA): Add new patches. * gnu/bootloader/u-boot.scm (install-pinebook-pro-rk3399-u-boot, u-boot-pinebook-pro-rk3399-bootloader): New variable. Co-authored-by: Jan Nieuwenhuizen <janneke@gnu.org> Vagrant Cascadian 2020-04-08Merge branch 'master' into core-updates... Conflicts: etc/news.scm gnu/local.mk gnu/packages/check.scm gnu/packages/cross-base.scm gnu/packages/gimp.scm gnu/packages/java.scm gnu/packages/mail.scm gnu/packages/sdl.scm gnu/packages/texinfo.scm gnu/packages/tls.scm gnu/packages/version-control.scm Marius Bakke 2020-04-06system: Allow for comma-separated keyboard layouts....Reported by Florian Pelz <pelzflorian@pelzflorian.de>. * gnu/bootloader/grub.scm (keyboard-layout-file): Replace commas with hyphens in the first argument to 'computed-file'. * gnu/system/keyboard.scm (keyboard-layout->console-keymap): Likewise. * doc/guix.texi (Keyboard Layout): Add example. Ludovic Courtès 2020-03-29gnu: bootloader: Add grub-minimal-bootloader....* gnu/bootloader/grub.scm (grub-minimal-bootloader): New variable. Jan Nieuwenhuizen 2020-03-17bootloader: grub: Refactor eye-candy a bit....* gnu/bootloader/grub.scm (eye-candy)[setup-gfxterm-body]: Define the GFXMODE binding using AND-LET* instead of chained AND=>. Add a comment about supporting graphical mode on other systems than x86. Generate configuration string using FORMAT rather than STRING-APPEND. Maxim Cournoyer 2020-03-17bootloader: grub: Use the all_video module in graphic mode....* gnu/bootloader/grub.scm (eye-candy): Load the module 'all_video' which automatically loads all the available and relevant video modules. Maxim Cournoyer 2020-02-02gnu: Add u-boot-cubietruck-bootloader....* gnu/bootloader/u-boot.scm (u-boot-cubietrack-bootloader): New variable. Julien Lepiller 2020-01-25bootloader: grub: Add gfxmode (resolution) override....* gnu/bootloader/grub.scm (<grub-theme>): Add `gfxmode' entry. (eye-candy): Use it. * doc/guix.texi (Bootloader Configuration): Document it. Jan Nieuwenhuizen 2020-01-07Revert "bootloader: grub: Add gfxmode (resolution) override."...This reverts commit a23091880d4dc6115acbfa3b7ef09d731fc5abb0. It causes ‘guix pull’ to fail: <https://paste.debian.net/plain/1125061>. Tobias Geerinckx-Rice 2020-01-07bootloader: grub: Add gfxmode (resolution) override....* gnu/bootloader/grub.scm (<grub-theme>): Add `gfxmode' entry. (eye-candy): Use it. * doc/guix.texi (Bootloader Configuration): Document it. Jan Nieuwenhuizen 2020-01-06Adjust module autoloads....In Guile < 2.9.7, autoloading a module would give you access to all its bindings. In future versions, autoloading a module gives access only to the listed bindings, as per #:select (see <https://bugs.gnu.org/38895>). This commit adjusts autoloads to the new semantics, allowing Guix to be built with Guile 2.9.7/2.9.8. * guix/build/download.scm <top level>: Remove call to 'module-autoload!'. (load-gnutls): New procedure. (tls-wrap): Call it. * guix/git.scm <top level>: Remove call to 'module-autoload!'. (load-git-submodules): New procedure. (update-submodules): Call it instead of 'resolve-interface'. * gnu/bootloader/grub.scm: Replace #:autoload with #:use-module. * gnu/packages.scm: Likewise. * gnu/packages/ssh.scm: Likewise. * gnu/packages/tex.scm: Likewise. * gnu/services/cuirass.scm: Likewise. * gnu/services/mcron.scm: Likewise. * guix/lint.scm: Augment list of bindings in #:autoload. * guix/scripts/build.scm: Likewise. * guix/scripts/gc.scm: Likewise. * guix/scripts/pack.scm: Likewise. * guix/scripts/publish.scm: Likewise. * guix/scripts/pull.scm: Likewise. * guix/utils.scm: Remove unnecessary #:autoload clauses; replace one of them with #:use-module. Ludovic Courtès 2020-01-03bootloader: Mark "grub.cfg" and "extlinux.conf" as non-substitutable....Suggested by <pkill9@runbox.com>. * gnu/bootloader/grub.scm (grub-configuration-file): Pass #:options to 'computed-file'. * gnu/bootloader/extlinux.scm (extlinux-configuration-file): Likewise. Ludovic Courtès 2019-12-23bootloader: grub: Add firmware setup entry....* gnu/bootloader/grub.scm (grub-configuration-file): Add 'Firmware setup' entry for EFI platform. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> Brice Waegeneire 2019-12-14gnu: Add u-boot-pine64-lts-bootloader....* gnu/bootloader/u-boot.scm (u-boot-pine64-lts-bootloader): New variable. Mathieu Othacehe 2019-10-18gnu: Add u-boot-firefly-rk3399....* gnu/packages/bootloaders (u-boot-firefly-rk3399): New variable. * gnu/bootloader/u-boot (install-firefly-rk3399-u-boot): New variable. (u-boot-firefly-rk3399-bootloader): New variable. * gnu/system/install (define firefly-rk3399-installation-os): New variable. Vagrant Cascadian 2019-10-18gnu: Add u-boot-rock64-rk3328....* gnu/packages/bootloaders (u-boot-rock64-rk3328): New variable. * gnu/bootloader/u-boot (install-rock64-rk3328-u-boot): New variable. (u-boot-rock64-rk3328-bootloader): New variable. * gnu/system/install (define rock64-installation-os): New variable. Vagrant Cascadian 2019-10-18gnu: Add u-boot-rockpro64-rk3399...* gnu/packages/bootloaders.scm (u-boot-rockpro64-rk3399): New exported variable. (u-boot-2019.10): New variable. * gnu/bootloader/u-boot.scm (u-boot-rockpro64-rk3399-bootloader): New exported variable. (install-rockpro64-rk3399-u-boot): New variable. * gnu/system/install.scm (rockpro64-installation-os): New exported variable. Adjusted-by: Vagrant Cascadian <vagrant@debian.org> Signed-off-by: Caliph Nomble <nomble@palism.com> Signed-off-by: Vagrant Cascadian <vagrant@debian.org> Caliph Nomble 2019-05-09bootloader: grub: Remove unneeded 'terminal_output'....Fixes <https://bugs.gnu.org/35585>. Reported by Florian Pelz <pelzflorian@pelzflorian.de>. This statement was added in 8d058e7b1b1a409d3d9cc29c5650a98db4e78783 but turned out to be unnecessary. * gnu/bootloader/grub.scm (grub-configuration-file): Remove 'terminal_output' statement. Ludovic Courtès 2019-04-29gnu: u-boot: Update to 2019.04....* gnu/packages/bootloaders.scm (u-boot): Update to 2019.04. [source]: Add patch. (u-boot-novena): Update dynamic patch to handle config key rename. (u-boot-am335x-evm): New variable. (u-boot-am335x-boneblack): Build with modified am335x-evm config. (u-boot-novena): Fix typo in description. * gnu/bootloader/u-boot.scm (u-boot-beaglebone-black-bootloader): Use u-boot-am335x-boneblack. * gnu/packages/patches/u-boot-fix-mkimage-header-verification.patch: New file. * gnu/local.mk (dist_patch_DATA): Update accordingly. Signed-off-by: Danny Milosavljevic <dannym@scratchpost.org> Vagrant Cascadian 2019-04-03gnu: Add configuration for depthcharge bootloader....* gnu/bootloader/depthcharge: New file. * gnu/local.mk [GNU_SYSTEM_MODULES]: Adjust accordingly. Signed-off-by: Ludovic Courtès <ludo@gnu.org> Timothy Sample 2019-03-24bootloader: Add a 'keyboard-layout' field....* gnu/bootloader/grub.scm (keyboard-layout-file): New procedure. (grub-configuration-file)[keyboard-layout-file]: New variable. [builder]: Use it. * gnu/bootloader.scm (<bootloader-configuration>)[keyboard-layout]: New field. * doc/guix.texi (Bootloader Configuration): Document it. Co-authored-by: nee <nee-git@hidamari.blue> Ludovic Courtès 2019-03-16bootloader: Use 'invoke/quiet' when running 'grub-install' and co....This hides potentially confusing GRUB messages from the user, such as "Installing for i386-pc platform." * gnu/bootloader/extlinux.scm (install-extlinux): Use 'invoke/quiet' instead of 'system*' and 'error'. * gnu/bootloader/grub.scm (install-grub, install-grub-efi): Likewise. * guix/scripts/system.scm (bootloader-installer-script): Guard against 'message-condition?' and handle them properly. Ludovic Courtès 2019-03-13Remove traces of "GuixSD"....* gnu/bootloader/extlinux.scm (extlinux-configuration-file): Remove mentions of "GuixSD". * gnu/bootloader/grub.scm (install-grub-efi): Likewise. * gnu/build/vm.scm (make-iso9660-image): Change default #:volume-id to "Guix_image". (initialize-hard-disk): Search for the "Guix_image" label. * gnu/ci.scm (system-test-jobs, tarball-jobs): Remove "GuixSD". * gnu/installer/newt/welcome.scm (run-welcome-page): Likewise. * gnu/packages/audio.scm (supercollider)[description]: Likewise. * gnu/packages/curl.scm (curl): Likewise. * gnu/packages/emacs.scm (emacs): Likewise. * gnu/packages/gnome.scm (network-manager): Likewise. * gnu/packages/julia.scm (julia): Likewise. * gnu/packages/linux.scm (alsa-plugins): Likewise. (powertop, wireless-regdb): Likewise. * gnu/packages/package-management.scm (guix): Likewise. * gnu/packages/polkit.scm (polkit): Likewise. * gnu/packages/tex.scm (texlive-bin): Likewise. * gnu/services/base.scm (file-systems->fstab): Likewise. * gnu/services/cups.scm (%cups-activation): Likewise. * gnu/services/mail.scm (%dovecot-activation): Likewise. * gnu/services/messaging.scm (prosody-configuration)[log]: Likewise. * gnu/system/examples/vm-image.tmpl (vm-image-motd): Likewise. * gnu/system/install.scm (installation-os)[file-systems]: Change root file system label to "Guix_image". * gnu/system/mapped-devices.scm (check-device-initrd-modules): Remove "GuixSD". * gnu/system/vm.scm (system-docker-image): Likewise. (system-disk-image)[root-label]: Change to "Guix_image". * gnu/tests/install.scm (run-install): Remove "GuixSD". * guix/modules.scm (guix-module-name?): Likewise. * nix/libstore/optimise-store.cc: Likewise. Ludovic Courtès