summaryrefslogtreecommitdiff
path: root/home/desktops/sway/config.nix
blob: 19077af85c3f373f3a06cd3a3b4023911f78d29e (plain)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
{
  config,
  lib,
  ...
}: {
  wayland.windowManager.sway = {
    config = {
      # monitors
      output =
        (builtins.listToAttrs (map (mon: {
            name =
              if mon.desc == ""
              then mon.port
              else mon.desc;
            value =
              {
                dpms = "on";
                scale = toString mon.scale;
                render_bit_depth = toString mon.bitdepth;
              }
              // lib.optionalAttrs mon.position.enabled {
                position = "${toString mon.position.x} ${toString mon.position.y}";
              }
              // lib.optionalAttrs mon.size.enabled {
                mode = "${toString mon.size.x}x${toString mon.size.y}";
              };
          })
          config.monitors))
        // {
          # wallpaper
          "*" = {
            bg = "${config.theme.wallpaper} fill";
          };
        };

      # inputs
      input = {
        "*" = {
          xkb_layout = "us";
          xkb_options = "compose:ralt";
          xkb_numlock = "enable";
        };

        "type:touchpad" = {
          tap = "enabled";
          natural_scroll = "enabled";
          middle_emulation = "enabled";
        };
      };

      startup =
        # autostart apps
        map (command: {
          inherit command;
          always = false;
        })
        config.autoRun;

      # colors
      colors = let
        base = "#${config.theme.colors.base}";
        surface = "#${config.theme.colors.surface}";
        primary = "#${config.theme.colors.primary}";
        text = "#${config.theme.colors.text}";
        white = "#${config.theme.colors.bright.white}";
        error = "#${config.theme.colors.error}";
      in rec {
        background = base;

        focused = {
          border = primary;
          background = base;
          indicator = white;
          childBorder = primary;
          inherit text;
        };

        focusedInactive = {
          border = surface;
          background = base;
          indicator = surface;
          childBorder = surface;
          inherit text;
        };

        unfocused = focusedInactive;

        urgent = {
          border = error;
          background = error;
          indicator = error;
          childBorder = error;
          inherit text;
        };

        placeholder = unfocused;
      };

      window = {
        titlebar = false;
        border = config.theme.borderWidth;
      };

      floating = {
        titlebar = false;
        border = config.theme.borderWidth;
        modifier = "Mod4 normal";
      };

      gaps = {
        inner = config.theme.innerGap;
        outer = config.theme.outerGap;
      };

      modes = {};
      bars = [];
    };

    extraConfig = ''
      # gestures
      bindgesture swipe:right workspace prev
      bindgesture swipe:left workspace next

      # swayfx
      corner_radius ${toString config.theme.outerRadius}
      smart_corner_radius ${toString config.theme.outerRadius}
      blur ${
        if config.theme.blur
        then "enabled"
        else "disabled"
      }
      blur_radius 10
      blur_passes 3
    '';
  };
}