about summary refs log tree commit diff
path: root/modules/workstation/hardware/keyboard
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-07-07 18:57:34 +0000
committerAlyssa Ross <hi@alyssa.is>2019-08-13 21:59:11 +0000
commit4d4afdb420b71ab296be7e2d4b3d8109f2a27991 (patch)
tree960345c7e6c65f678bb5eed19ec53b35be3adfc3 /modules/workstation/hardware/keyboard
parent457035d7a68d7a31c2630b59cb1d4b73792424eb (diff)
downloadnixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.tar
nixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.tar.gz
nixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.tar.bz2
nixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.tar.lz
nixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.tar.xz
nixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.tar.zst
nixlib-4d4afdb420b71ab296be7e2d4b3d8109f2a27991.zip
modules/hardware: reorganize
It made far more sense for Yubikey stuff to be in here. Also, there was
a lot of keyboard-related stuff, so made sense to give that its own
module.
Diffstat (limited to 'modules/workstation/hardware/keyboard')
-rw-r--r--modules/workstation/hardware/keyboard/MAPPINGS7
-rw-r--r--modules/workstation/hardware/keyboard/default.nix22
-rw-r--r--modules/workstation/hardware/keyboard/events.dyon14
3 files changed, 43 insertions, 0 deletions
diff --git a/modules/workstation/hardware/keyboard/MAPPINGS b/modules/workstation/hardware/keyboard/MAPPINGS
new file mode 100644
index 000000000000..60ded39c8cf1
--- /dev/null
+++ b/modules/workstation/hardware/keyboard/MAPPINGS
@@ -0,0 +1,7 @@
+Key remappings are spread across several different places, because they
+have to be done differently depending on the remapping.
+
+Here is an overview of remapped keys:
+
+Caps Lock: Escape if pressed, Ctrl if held
+Tab: Super-L if pressed, Tab if held
diff --git a/modules/workstation/hardware/keyboard/default.nix b/modules/workstation/hardware/keyboard/default.nix
new file mode 100644
index 000000000000..d2b13640277c
--- /dev/null
+++ b/modules/workstation/hardware/keyboard/default.nix
@@ -0,0 +1,22 @@
+{ pkgs, config, ... }:
+
+let
+  xcfg = config.services.xserver;
+
+in
+{
+  i18n.consoleUseXkbConfig = true;
+  services.xserver.layout = "dvorak";
+  services.xserver.xkbOptions = "ctrl:nocaps,compose:menu";
+
+  environment.variables.XKB_DEFAULT_LAYOUT = xcfg.layout;
+  environment.variables.XKB_DEFAULT_OPTIONS = xcfg.xkbOptions;
+
+  services.evscript.enable = true;
+  services.evscript.script = ./events.dyon;
+
+  boot.postBootCommands = ''
+    # Remap tab to left super
+    /run/current-system/sw/bin/setkeycodes 0f 125
+  '';
+}
diff --git a/modules/workstation/hardware/keyboard/events.dyon b/modules/workstation/hardware/keyboard/events.dyon
new file mode 100644
index 000000000000..96cc15450e46
--- /dev/null
+++ b/modules/workstation/hardware/keyboard/events.dyon
@@ -0,0 +1,14 @@
+//! [events]
+//! keys = ['ESC', 'TAB']
+fn main() ~ evdevs, uinput {
+    should_esc := false
+    should_tab := false
+    loop {
+        evts := next_events(evdevs)
+        for i {
+            evt := evts[i]
+            xcape(mut should_esc, evt, KEY_CAPSLOCK(), [KEY_ESC()])
+            xcape(mut should_tab, evt, KEY_LEFTMETA(), [KEY_TAB()])
+        }
+    }
+}