summary refs log tree commit diff
path: root/modules/services/x11/hardware/multitouch.nix
blob: 4f9048bfd910be7d1b7610a953587086bcb7a596 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
{ config, pkgs, ... }:

with pkgs.lib;

let cfg = config.services.xserver.multitouch; in

{

  options = {

    services.xserver.multitouch = {

      enable = mkOption {
        default = false;
        example = true;
        description = "Whether to enable multitouch touchpad support.";
      };

      invertScroll = mkOption {
        default = false;
        example = true;
        type = types.bool;
        description = "Whether to invert scrolling direction à la OSX Lion";
      };

      ignorePalm = mkOption {
        default = false;
        example = true;
        type = types.bool;
        description = "Whether to ignore touches detected as being the palm (i.e when typing)";
      };

    };

  };

  config = mkIf cfg.enable {

    services.xserver.modules = [ pkgs.xf86_input_mtrack ];

    services.xserver.config =
      ''
        # Automatically enable the multitouch driver
        Section "InputClass"
          MatchIsTouchpad "on"
          Identifier "Touchpads"
          Driver "mtrack"
          Option "IgnorePalm" "${if cfg.ignorePalm then "true" else "false"}"
          ${optionalString cfg.invertScroll ''
            Option "ScrollUpButton" "5"
            Option "ScrollDownButton" "4"
            Option "ScrollLeftButton" "7"
            Option "ScrollRightButton" "6"
          ''}
        EndSection
      '';

  };

}