You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

111 lines
3.3 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. # This is a custom file for a surface.
  2. { config, lib, pkgs, modulesPath, ... }:
  3. {
  4. environment.systemPackages = with pkgs; [
  5. obs-studio
  6. rnote
  7. xournalpp
  8. ];
  9. # Set an usable key configuration: Ctrl at capslock, Win at Alt, Alt at Ctrl
  10. services.xserver.displayManager.sessionCommands =''
  11. ${pkgs.xorg.xmodmap}/bin/xmodmap "${pkgs.writeText "xkb-layout" ''
  12. !
  13. ! Swap Caps_Lock and Control_L
  14. !
  15. remove Lock = Caps_Lock
  16. remove Control = Control_L
  17. ! keysym Control_L = Caps_Lock
  18. keysym Control_L = Mode_switch
  19. keysym Caps_Lock = Control_L
  20. add Lock = Caps_Lock
  21. add Control = Control_L
  22. ! map arrows to more ergonomic position
  23. keycode 43 = h H Left
  24. keycode 44 = j J Down
  25. keycode 45 = k K Up
  26. keycode 46 = l L Right
  27. ''}"
  28. '';
  29. # add pulseaudio support to manage audio
  30. hardware.pulseaudio.enable = true;
  31. # prevent suspend on folding
  32. services.logind.lidSwitch = "ignore";
  33. # next sleep & wake is code from: https://github.com/hpfr/system/blob/2e5b3b967b0436203d7add6adbd6b6f55e87cf3c/hosts/linux-surface.nix
  34. # systemd.services = {
  35. # surface-sleep = {
  36. # enable = lib.versionOlder config.boot.kernelPackages.kernel.version "5.4";
  37. # before = [ "suspend.target" ];
  38. # wantedBy = [ "suspend.target" ];
  39. # serviceConfig.Type = "oneshot";
  40. # path = with pkgs; [ procps kmod bluez ];
  41. # script = ''
  42. # # Disable bluetooth if no device is connected
  43. # if ps cax | grep bluetoothd && ! bluetoothctl info; then
  44. # bluetoothctl power off
  45. # fi
  46. # ## Disable bluetooth regardless if devices are connected (see notes below)
  47. # # if ps cax | grep bluetoothd; then
  48. # # bluetoothctl power off
  49. # # fi
  50. # ## > Remove IPTS from ME side
  51. # modprobe -r ipts_surface
  52. # modprobe -r intel_ipts
  53. # # modprobe -r mei_hdcp
  54. # modprobe -r mei_me
  55. # modprobe -r mei
  56. # ## > Remove IPTS from i915 side
  57. # for i in $(find /sys/kernel/debug/dri -name i915_ipts_cleanup); do
  58. # echo 1 > $i
  59. # done
  60. # '';
  61. # };
  62. # surface-wake = {
  63. # enable = lib.versionOlder config.boot.kernelPackages.kernel.version "5.4";
  64. # after = [ "post-resume.target" ];
  65. # wantedBy = [ "post-resume.target" ];
  66. # serviceConfig.Type = "oneshot";
  67. # path = with pkgs; [ procps kmod bluez ];
  68. # script = ''
  69. # ## > Load IPTS from i915 side
  70. # for i in $(find /sys/kernel/debug/dri -name i915_ipts_init); do
  71. # echo 1 > $i
  72. # done
  73. # ## > Load IPTS from ME side
  74. # modprobe mei
  75. # modprobe mei_me
  76. # # modprobe mei_hdcp
  77. # modprobe intel_ipts
  78. # modprobe ipts_surface
  79. # # Restart bluetooth
  80. # if ps cax | grep bluetoothd; then
  81. # bluetoothctl power on
  82. # fi
  83. # '';
  84. # };
  85. # };
  86. ## NOTES:
  87. # Susspend issue:
  88. # https://github.com/linux-surface/linux-surface/wiki/Known-Issues-and-FAQ#suspend-aka-sleep-vs-lid-closingopening-events
  89. # run:
  90. # > sudo modprobe -r surface_gpe
  91. # and:
  92. # > sudo bash -c 'echo -e "\n# Blacklisting lid vs. suspend issue module\nblacklist surface_gpe" >> /etc/modprobe.d/blacklist.conf'
  93. #
  94. # Now folding the keyboard to the screen will not suspend and brick the
  95. # session, but you will need to manually suspend the session if saving battery
  96. # is desired.
  97. }