configs/nixos/surface-extra-hardware-configuration.nix
nixos/surface-extra-hardware-configuration.nixRaw
1# This is a custom file for a surface.
2
3{ config, lib, pkgs, modulesPath, ... }:
4
5{
6 # Set an usable key configuration: Ctrl at capslock, Win at Alt, Alt at Ctrl
7 services.xserver.displayManager.sessionCommands =''
8 ${pkgs.xorg.xmodmap}/bin/xmodmap "${pkgs.writeText "xkb-layout" ''
9 !
10 ! Swap Caps_Lock and Control_L
11 !
12
13 remove Lock = Caps_Lock
14 remove Control = Control_L
15 ! keysym Control_L = Caps_Lock
16 keysym Control_L = Mode_switch
17 keysym Caps_Lock = Control_L
18 add Lock = Caps_Lock
19 add Control = Control_L
20
21 ! map arrows to more ergonomic position
22 keycode 43 = h H Left
23 keycode 44 = j J Down
24 keycode 45 = k K Up
25 keycode 46 = l L Right
26 ''}"
27 '';
28
29
30 # add pulseaudio support to manage audio
31 hardware.pulseaudio.enable = true;
32
33## NOTES:
34# Susspend issue:
35# https://github.com/linux-surface/linux-surface/wiki/Known-Issues-and-FAQ#suspend-aka-sleep-vs-lid-closingopening-events
36# run:
37# > sudo modprobe -r surface_gpe
38# and:
39# > sudo bash -c 'echo -e "\n# Blacklisting lid vs. suspend issue module\nblacklist surface_gpe" >> /etc/modprobe.d/blacklist.conf'
40#
41# Now folding the keyboard to the screen will not suspend and brick the
42# session, but you will need to manually suspend the session if saving battery
43# is desired.
44}