From 86d982022e1885dbe1b504f97aa15b4c45d58f74 Mon Sep 17 00:00:00 2001 From: Raheman Vaiya Date: Fri, 20 Aug 2021 15:49:00 -0400 Subject: [PATCH] Make layert compatible with layer. --- CHANGELOG.md | 16 ++++++------- keyd.1.gz | Bin 3363 -> 3506 bytes man.md | 63 +++++++++++++++++++++++++++------------------------ src/main.c | 10 +++++--- 4 files changed, 49 insertions(+), 40 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 134f7aa..1b834a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,23 +1,23 @@ -# v1.0.1 +# v1.1.0 -- Added layert(). -- No resolve layer conflicts by picking the most recently activated one in the case of multiple mappings. +- Added layert() to facilitate semipermanent-activation of occluding layers. +- Now resolve layer conflicts by picking the most recently activated one. # v1.0.0 Major version update: - Introduces support for modifier layers. -- Simplifies config format. +- Simplifies the config format. - Improves consistency/expected key behaviour. -- Symbols can be used in place of their names (e.g `;` instead of `semicolon`) -- Shifted symbols can now be specified directly (e.g `&` instead of `S-7`) +- Symbols can now be assigned directly place of their names (e.g `&` instead of `S-7`). - Macro support. -This breaks existing configs. Moving forward the config format is expected to +*This breaks existing configs*. Moving forward the config format is expected to remain backwards compatible. Main Config Changes: + - Modifiers are now just treated as layers - The default layer is now called main - The modifier layout is distinct from the key layout @@ -34,4 +34,4 @@ oneshot_layer(layer) = oneshot(layer) [dvorak:default] = [dvorak:main] ``` -See the manpage for details. +See the [manpage](man.md) for details. diff --git a/keyd.1.gz b/keyd.1.gz index c725f111e803168d59b03c2c5d2a6824279dc563..1f3e5f87b67b0163842ec5e94e25bc1bd9928ad9 100644 GIT binary patch literal 3506 zcmV;j4NdYNiwFQ)2_Rtr1C?2AZ`;Tb{=UCr;R3CVbLiMtpn#DYaGYFXTwaXG>Gfb5 zy%o8Vwx&p#yR@Q1(cj)@W_Br3)?Hh`2}N>ucHZZiVU{20%Pura6I@}cYNO}2wyg=a z)YFZ=F?HD#`Yb!kPF0p4sOs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ayPrIz2M}{Sp$$(>2`X7*ZEdF)7SVVxm(@##QWvQ5m z%;OxiN*$@=Y8=6speg|YMXWUmTPSgcIND3lhUmmv9<4cHdTcJ!9OCf*(t+a6m8T9X z*H0Ji1oWi&-BlQ|y?fxyMl!|VeH5HxHx}(3z5SDd;Tg0Rhust_5uC3LJ4iq#kUljc zJxb?Fd~i)Lb;8}s6u#Ym#h1j~rS;=@U`Ie8p2E91Phllp$BpA;W;*iOe%hJ%#IJpO zXPc9=T;IrTob(W(H4|a1z@K)eJBaW6W%4b*jt3I3GUllr^ZwVE1~{*+lxi1$Vjr z+WNZW7m>;mJHRXd5rds6@Vw>+uwIu!>LOtok%I*^bA)gt6UoQze9FP3z$0l#wLVqq zM{`G9N`{Z5V|T;zDJf{c-MC5Hu4oL!&J$wN=mc zk-wyxGCNS-Etb!JQ8(Cn%NoMX_xE}1z{2PQ!a3QY~M->O=@-guIegp^bwk8|P1hTJY7WrJSUG$eu4wDF zkwKOEU9Rb^`o_=qN-X)Cdf@Awn)CIWl6`Zv;_FJWe0;xFkdN;k6c51o{`aZFzSo~V zU%#F0WSQ4i>VC{Il-arSShxNz5H=v7Ie~_rs;Q@9K!YOS#Kr>Z4}sfL9zq#CH|1^@ zJ~ov@7KKEM)CH^^e?kgA4uoAR4 zsibk?>RSa!R!-Yzn`+q|t>Pc-5|dCx6e6;?CD!;_u3rwIz7Y^Iy|I2g8EL6XE6S;f1oqv*FhHoC`|aBsU6NT^&i5Rc6o{)0007hvN8Yw diff --git a/man.md b/man.md index b034dee..7791fcb 100644 --- a/man.md +++ b/man.md @@ -1,15 +1,27 @@ -% WARP(1) +% KEYD(1) % Raheman Vaiya -# OVERVIEW +# NAME -A system-wide key remapping daemon. +**keyd** - A key remapping daemon. -# USAGE +# SYNOPSIS -keyd [-m] [-l] +**keyd** [**-m**] [**-l**] [**-d**] -# ARGS +# DESCRIPTION + +keyd is a system wide key remapping daemon which supports features like +layering, oneshot modifier, and macros. In its most basic form it can be used +to define a custom key layout that persists accross display server boundaries +(e.g wayland/X/tty). + +keyd is intended to run as a systemd service but is capable of running +independently. The default behaviour is to run the forground and print to +stderr, unless **-d** is supplied, in which case in which case log output will +be stored in */var/log/keyd.log*. + +# OPTIONS **-m**: Run in monitor mode. (ensure keyd is not running to see untranslated events). @@ -17,18 +29,13 @@ keyd [-m] [-l] **-d**: Fork and run in the background. -keyd is intended to be run as system wide daemon managed by systemd. The -default behaviour is to run the forground and print to stderr but it can also -be run as a standalone daemon if -d is supplied, in which case log output will -be stored in */var/log/keyd.log*. - # CONFIGURATION -All configuration files are stored in */etc/keyd/*. The name of each file should -correspond to the device name to which it is to be applied followed -by .cfg (e.g "/etc/keyd/Magic Keyboard.cfg"). Configuration files are loaded -upon initialization and can be reified by reloading keyd -(e.g sudo systemctl restart keyd). +All configuration files are stored in */etc/keyd/*. The name of each file +should correspond to the device name to which it is to be applied followed by +.cfg (e.g "/etc/keyd/Magic Keyboard.cfg"). Configuration files are loaded upon +initialization and can be reified by reloading keyd (e.g sudo systemctl restart +keyd). A list of valid key names can be produced with **-l**. The monitor flag (**-m**) can also be used to obtain device and key names like so: @@ -81,8 +88,8 @@ is activated by holding the capslock key. [symbols] - f = S-grave - d = slash + f = ~ + d = / Pressing capslock+f thus produces a tilde. @@ -104,7 +111,7 @@ changed by including layout() at the top of the config file. ## The Modifier Layout -keyd distinguishes between the normal layout and the modifier layout. This +keyd distinguishes between the key layout and the modifier layout. This allows the user to use a different letter arrangement for modifiers. It may, for example, be desireable to use an alternative key layout like dvorak while preserving standard qwerty modifier shortcuts. This can be achieved by passing @@ -169,7 +176,7 @@ Where `` has the form ` [...]` where each token is one of Examples: - # Sends alt+p, waits 300ms (allowing the launcher time to start) and then sends 'chromium' before sending enter. + # Sends alt+p, waits 100ms (allowing the launcher time to start) and then sends 'chromium' before sending enter. macro(A-p 100ms chromium enter) # Types 'Hello World' @@ -178,27 +185,25 @@ Examples: # Identical to the above macro(Hello space World) -## Example - - # Makes dvorak the default key layout with - # qwerty (main) as the modifier layout. +# Example + # Set the default key layout to dvorak and the modifier layout to qwerty (main) layout(dvorak, main) + # Holding escape activates the escape layer esc = layer(esc) - leftshift = oneshot(S) + shift = oneshot(S) rightshift = oneshot(S) [esc] - # esc+q changes the layout to qwerty. + # esc+q changes both the key and modifier layout to qwerty. q = layout(main) - w = layout(dvorak, main) - # Inherits the escape/shift bindings from the main layer - + # Inherits all bindings from the main layer (including the defined escape/shift bindings), + # and defines a custom letter arrangement. [dvorak:main] q = apostrophe diff --git a/src/main.c b/src/main.c index 6d57915..c5ef2db 100644 --- a/src/main.c +++ b/src/main.c @@ -421,7 +421,7 @@ static void process_event(struct keyboard *kbd, struct input_event *ev) layer->active = 1; layer->timestamp = get_time(); } else if(pressed_timestamps[code] < last_keyseq_timestamp) { - layer->active = 0; + layer->active = !layer->active; } else //Tapped oneshot_layers[d->arg.layer] = 1; @@ -437,6 +437,7 @@ static void process_event(struct keyboard *kbd, struct input_event *ev) layer->active = !layer->active; } reify_layer_mods(kbd); + goto keyseq_cleanup; } break; case ACTION_LAYER: @@ -445,8 +446,11 @@ static void process_event(struct keyboard *kbd, struct input_event *ev) if(pressed) { layer->active = 1; layer->timestamp = get_time(); - } else - layer->active = 0; + } else { + //Toggle rather than clear to account for + //the possibility of interposed layert() + layer->active = !layer->active; + } reify_layer_mods(kbd); break;