summaryrefslogtreecommitdiff
path: root/nixos/modules/wm.nix
blob: 3d9314a4cb34638503cb308891d57ade0d903727 (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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
{ pkgs, ... }:

{
  xdg.configFile."hypr/hyprland.lua".force = true;

  wayland.windowManager.hyprland = {
    enable = true;
    configType = "lua";

    extraConfig = ''
      local hl = hl
      local dsp = hl.dsp
      local bind = hl.bind
      local config = hl.config
      local curve = hl.curve
      local animation = hl.animation
      local exec = dsp.exec_cmd
      local focus = dsp.focus
      local window = dsp.window
      local workspace = dsp.workspace

      hl.monitor({ output = "HDMI-A-1", mode = "1920x1080@200", position = "0x0", scale = 1 })
      hl.monitor({ output = "DP-1", mode = "1920x1080@144", position = "-1080x-330", scale = 1, transform = 3 })

      local mod = "SUPER"
      local terminal = "kitty"
      local browser = "helium"

      hl.on("hyprland.start", function ()
          hl.exec_cmd("systemctl --user start hyprpolkitagent")
          hl.exec_cmd("bash -c 'awww-daemon & sleep 0.5 && awww clear --outputs DP-1'")
          hl.exec_cmd("wl-paste --type text --watch cliphist store")
          hl.exec_cmd("wl-paste --type image --watch cliphist store")
          hl.exec_cmd("quickshell -p ~/.config/quickshell/shell.qml")
      end)

      config({
          general = {
              gaps_in = 2.5,
              gaps_out = 5,
              border_size = 1,
              resize_on_border = false,
              col = { active_border = "rgba(ffffffff)" },
              allow_tearing = false,
              layout = "dwindle",
          },
      })

      config({
          decoration = {
              rounding = 0,
              rounding_power = 0,
              active_opacity = 1.0,
              inactive_opacity = 1.0,
              shadow = {
                  enabled = true,
                  range = 4,
                  render_power = 3,
                  color = "rgba(1a1a1aee)",
              },
              blur = {
                  enabled = true,
                  size = 3,
                  passes = 3,
                  vibrancy = 0,
              },
          },
      })

      config({
          input = {
              kb_layout = "us",
              follow_mouse = 1,
              sensitivity = 0,
              force_no_accel = false,
              touchpad = { natural_scroll = false },
          },
      })

      config({
          misc = {
              force_default_wallpaper = 0,
              disable_hyprland_logo = true,
              disable_splash_rendering = true,
              initial_workspace_tracking = true,
          },
      })

      config({
          dwindle = {
              preserve_split = true,
          },
      })

      curve("easeOutQuint", { type = "bezier", points = { {0.20, 1}, {0.30, 1} } })
      curve("easeInOutCubic", { type = "bezier", points = { {0.65, 0.05}, {0.35, 1} } })
      curve("linear", { type = "bezier", points = { {0, 0}, {1, 1} } })
      curve("almostLinear", { type = "bezier", points = { {0.5, 0.5}, {0.75, 1} } })
      curve("quick", { type = "bezier", points = { {0.15, 0}, {0.1, 1} } })
      curve("hard", { type = "bezier", points = { {0, 1}, {0, 1} } })
      animation({ leaf = "global", enabled = true, speed = 5, bezier = "default" })
      animation({ leaf = "border", enabled = true, speed = 2.5, bezier = "easeOutQuint" })
      animation({ leaf = "windows", enabled = true, speed = 2.5, bezier = "easeOutQuint" })
      animation({ leaf = "windowsIn", enabled = true, speed = 2, bezier = "easeOutQuint", style = "popin 90%" })
      animation({ leaf = "windowsOut", enabled = true, speed = 1, bezier = "linear", style = "popin 90%" })
      animation({ leaf = "fadeIn", enabled = true, speed = 1, bezier = "almostLinear" })
      animation({ leaf = "fadeOut", enabled = true, speed = 1, bezier = "almostLinear" })
      animation({ leaf = "fade", enabled = true, speed = 1.5, bezier = "quick" })
      animation({ leaf = "layers", enabled = true, speed = 2, bezier = "easeOutQuint" })
      animation({ leaf = "layersIn", enabled = true, speed = 2, bezier = "easeOutQuint", style = "fade" })
      animation({ leaf = "layersOut", enabled = true, speed = 1, bezier = "linear", style = "fade" })
      animation({ leaf = "workspaces", enabled = true, speed = 5, bezier = "hard", style = "slidevert" })
      animation({ leaf = "specialWorkspace", enabled = true, speed = 5, bezier = "hard", style = "slidevert" })

      hl.window_rule({
          match = { initial_class = "^(imv|mpv)$" },
          float = true,
          center = true,
          size = "600 600",
      })

      bind(mod .. " + Q", exec(terminal))
      bind(mod .. " + R", exec("quickshell ipc call menu toggle"))
      bind(mod .. " + T", exec("quickshell ipc call master toggle"))
      bind(mod .. " + W", exec("quickshell ipc call bar toggle"))
      bind(mod .. " + X", exec("quickshell ipc call mic toggle"))
      bind(mod .. " + B", exec(browser))
      bind(mod .. " + C", window.close())
      bind(mod .. " + V", window.float({ action = "toggle" }))
      bind(mod .. " + F", window.fullscreen({ mode = 0 }))
      bind(mod .. " + Tab", focus({ workspace = "m+1" }))
      bind("ALT + S", exec('hyprshot -o .pictures/screenshots/ -f "$(date +%y-%m-%d_%H-%M-%S).png" -s -m region'))

      bind(mod .. " + left",  focus({ direction = "left" }))
      bind(mod .. " + right", focus({ direction = "right" }))
      bind(mod .. " + up",    focus({ direction = "up" }))
      bind(mod .. " + down",  focus({ direction = "down" }))

      bind("SHIFT + left",  window.move({ direction = "left" }))
      bind("SHIFT + right", window.move({ direction = "right" }))
      bind("SHIFT + up",    window.move({ direction = "up" }))
      bind("SHIFT + down",  window.move({ direction = "down" }))

      for i = 1, 10 do
          local key = (i == 10) and "0" or tostring(i)
          bind(mod .. " + " .. key, focus({ workspace = i }))
          bind(mod .. " + SHIFT + " .. key, window.move({ workspace = i }))
      end

      bind(mod .. " + S", workspace.toggle_special("magic"))
      bind(mod .. " + SHIFT + " .. "S", window.move({ workspace = "special:magic" }))

      bind(mod .. " + mouse:272", window.drag(), { mouse = true })
      bind(mod .. " + mouse:273", window.resize(), { mouse = true })
    '';
  };
}