about summary refs log tree commit diff
path: root/modules/workstation/hardware
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2019-02-18 01:10:55 +0000
committerAlyssa Ross <hi@alyssa.is>2019-02-18 01:10:55 +0000
commit7fbd32a525182f2089e1098723219a1a4ef264bb (patch)
treebc81df65c59acb73f854e55a72b6c06ea3b6532a /modules/workstation/hardware
parent95e667e9cda7c2611b9f3f97881134554e8e02d1 (diff)
downloadnixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.tar
nixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.tar.gz
nixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.tar.bz2
nixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.tar.lz
nixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.tar.xz
nixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.tar.zst
nixlib-7fbd32a525182f2089e1098723219a1a4ef264bb.zip
keyboard: map caps lock to control/escape
Diffstat (limited to 'modules/workstation/hardware')
-rw-r--r--modules/workstation/hardware/default.nix13
-rw-r--r--modules/workstation/hardware/events.dyon12
2 files changed, 24 insertions, 1 deletions
diff --git a/modules/workstation/hardware/default.nix b/modules/workstation/hardware/default.nix
index a81508c7ed3b..bd5bd9ce12e8 100644
--- a/modules/workstation/hardware/default.nix
+++ b/modules/workstation/hardware/default.nix
@@ -1,6 +1,17 @@
-{ ... }:
+{ pkgs, config, ... }:
 
+let
+  xcfg = config.services.xserver;
+
+in
 {
   i18n.consoleUseXkbConfig = true;
   services.xserver.layout = "dvorak";
+  services.xserver.xkbOptions = "ctrl:nocaps";
+
+  environment.variables.XKB_DEFAULT_LAYOUT = xcfg.layout;
+  environment.variables.XKB_DEFAULT_OPTIONS = xcfg.xkbOptions;
+
+  services.evscript.enable = true;
+  services.evscript.script = ./events.dyon;
 }
diff --git a/modules/workstation/hardware/events.dyon b/modules/workstation/hardware/events.dyon
new file mode 100644
index 000000000000..2d8c8bfa87df
--- /dev/null
+++ b/modules/workstation/hardware/events.dyon
@@ -0,0 +1,12 @@
+//! [events]
+//! keys = ['ESC']
+fn main() ~ evdevs, uinput {
+    should_esc := false
+    loop {
+        evts := next_events(evdevs)
+        for i {
+            evt := evts[i]
+            xcape(mut should_esc, evt, KEY_CAPSLOCK(), [KEY_ESC()])
+        }
+    }
+}