From a566e0208f2134e69e4550d1c05fc49d2b3c6efd Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 5 Apr 2020 15:26:16 -0400 Subject: Swap caps+escape and alt+super only on chupacabra laptop keyboard --- home/machines/chupacabra.nix | 28 ++++++++++++++++++++++++++-- system/machines/bumblebee.nix | 2 ++ system/modules/xserver.nix | 1 - 3 files changed, 28 insertions(+), 3 deletions(-) diff --git a/home/machines/chupacabra.nix b/home/machines/chupacabra.nix index 714348e3f174..c0d1fce431fb 100644 --- a/home/machines/chupacabra.nix +++ b/home/machines/chupacabra.nix @@ -1,7 +1,31 @@ -{ ... }: -{ +{ pkgs, ... }: +let + laptopKeyboardId = "25"; +in { system.machine = { wirelessInterface = "wlp59s0"; i3FontSize = 9; }; + + systemd.user.services.laptop-keyboard = { + Unit = { + Description = "Swap caps+escape and alt+super, but only on the built-in laptop keyboard"; + After = [ "graphical-session-pre.target" ]; + PartOf = [ "graphical-session.target" ]; + }; + + Install = { WantedBy = [ "graphical-session.target" ]; }; + + Service = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = ( + "${pkgs.xorg.setxkbmap}/bin/setxkbmap " + + "-device ${laptopKeyboardId} " + + "-option caps:swapescape " + + "-option compose:ralt " + + "-option altwin:swap_alt_win" + ); + }; + }; } diff --git a/system/machines/bumblebee.nix b/system/machines/bumblebee.nix index a1cd3ffa143d..0fec21409255 100644 --- a/system/machines/bumblebee.nix +++ b/system/machines/bumblebee.nix @@ -18,4 +18,6 @@ action = "hibernate"; thresholdPercentage = 5; }; + + services.xserver.xkbOptions = "caps:swapescape"; } diff --git a/system/modules/xserver.nix b/system/modules/xserver.nix index 52f04e2e6a69..2638f075249c 100644 --- a/system/modules/xserver.nix +++ b/system/modules/xserver.nix @@ -4,7 +4,6 @@ services.xserver = { enable = true; layout = "us"; - xkbOptions = "caps:swapescape"; libinput.enable = true; -- cgit 1.4.1