summaryrefslogtreecommitdiff
path: root/home/desktops/hyprland/hyprland.lua
blob: 8079bbc7f0d6cbdd6c1b815b15a1ab7785b975b8 (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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
--[[

  Hyprland Configuration
  Copyright (c) Freya Murphy 2026

]]--

--[[ PLUGINS ]]--

local hy3 = hl.plugin.hy3

--[[ LIB ]]--

local function exec(cmd)
  return hl.dsp.exec_cmd(cmd)
end

local function bind(keys, cb, opts)
  hl.bind(table.concat(keys, " + "), cb, opts or {})
end

local function rgb(color)
  return "rgb(" .. color .. ")"
end

local function animation(leaf, speed, bezier, style)
  hl.animation({
    leaf = leaf,
    enabled = true,
    speed = speed,
    bezier = bezier,
    style = style,
  })
end

--[[ GENERAL ]]--

hl.config({
  general = {
    resize_on_border = true,
    extend_border_grab_area = 20,
  },
})

--[[ MONITORS ]]--

for _,monitor in pairs(config.monitors) do
  local opts = {
    scale = monitor.scale,
    bitdepth = monitor.bitdepth,
  }

  -- output
  if monitor.desc == "" then
    opts.output = monitor.port
  else
    opts.output = "desc:" .. monitor.desc
  end

  -- mode
  if monitor.size.enabled then
    opts.mode = monitor.size.x .. "x" .. monitor.size.y
  else
    opts.mode = "preferred"
  end

  -- position
  if monitor.position.enabled then
    opts.position = monitor.position.x .. "x" .. monitor.position.y
  else
    opts.position = "auto"
  end

  hl.monitor(opts)
end

--[[ ENVIRONMENT ]]--

hl.env("XDG_CURRENT_DESKTOP", "Hyprland")
hl.env("XDG_SESSION_TYPE", "wayland")
hl.env("XDG_SESSION_DESKTOP", "Hyprland")

hl.env("HYPRCURSOR_THEME", "rose-pine-hyprcursor")
hl.env("HYPRCURSOR_SIZE", "24")

--[[ KEYBINDS ]]--

local mod = "SUPER"

-- Launch programs
bind({mod, "D"},      exec(config.default.appLauncher))
bind({mod, "W"},      exec(config.default.browser))
bind({mod, "L"},      exec(config.default.lockScreen))
bind({mod, "Return"}, exec(config.default.terminal))
bind({"Print"},       exec("grimblast copy area"))

-- Misc
bind({mod, "SHIFT", "L"}, hl.dsp.exit())

-- Window operations
bind({mod, "SHIFT", "Q"},     hl.dsp.window.close())
bind({mod, "SHIFT", "SPACE"}, hl.dsp.window.float({ action = "toggle" }))
bind({mod, "F"},              hl.dsp.window.fullscreen({ action = "toggle" }))
bind({mod, "J"},              hl.dsp.layout("togglesplit"))

-- Move focus with mod + arrow keys
-- Move window across workspace with mod + arrow keys
for _,direction in pairs({"left", "right", "up", "down"}) do
  bind({mod, direction},          hy3.move_focus(direction))
  bind({mod, "SHIFT", direction}, hy3.move_window(direction))
end

-- Switch workspaces with mod + [0-9]
-- Move active window to a workspace with mod + SHIFT + [0-9]
-- Move to tab in tab group
for i = 1, 10 do
  local key = i % 10
  bind({mod, key},          hl.dsp.focus({ workspace = i }))
  bind({mod, "SHIFT", key}, hl.dsp.window.move({ workspace = i, follow = false }))
  bind({"ALT", key},        hy3.focus_tab({ index = i }))
end

-- Hy3 groups and tab groups
bind({mod, "SHIFT", "B"}, hy3.make_group("h"))
bind({mod, "SHIFT", "V"}, hy3.make_group("v"))
bind({mod, "SHIFT", "C"}, hy3.change_group("toggletab"))

-- Scroll through existing workspaces with mod + scroll
bind({mod, "mouse_down"}, hl.dsp.focus({ workspace = "e+1" }))
bind({mod, "mouse_up"},   hl.dsp.focus({ workspace = "e-1" }))

-- Focus windows with scroll wheel or middle click
bind({"mouse_down"},  hy3.focus_tab({ direction = "l", mouse = "require_hovered" }))
bind({"mouse_up"},    hy3.focus_tab({ direction = "r", mouse = "require_hovered" }))

-- Move/resize windows with mod + LMB/RMB and dragging
bind({mod, "mouse:272"}, hl.dsp.window.drag(), { mouse = true })
bind({mod, "mouse:273"}, hl.dsp.window.resize(), { mouse = true })

-- Audio
bind({"XF86AudioRaiseVolume"},  exec("wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"))
bind({"XF86AudioLowerVolume"},  exec("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"))
bind({"XF86AudioMute"},         exec("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"))
bind({"XF86AudioMicMute"},      exec("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"))

-- Media
bind({"XF86AudioPlay"},         exec("playerctl play-pause"))
bind({"XF86AudioNext"},         exec("playerctl next"))
bind({"XF86AudioPrev"},         exec("playerctl previous"))

-- Backlight
bind({"XF86MonBrightnessDown"}, exec("brightnessctl set 5%-"))
bind({"XF86MonBrightnessUp"},   exec("brightnessctl set 5%+"))

--[[ THEME ]]--

hl.config({
  general = {
    gaps_in = config.theme.innerGap,
    gaps_out = config.theme.outerGap,
    border_size = config.theme.borderWidth,
    col = {
      active_border = rgb(config.theme.colors.primary),
      inactive_border = rgb(config.theme.colors.surface),
    },
  },
  decoration = {
    rounding = config.theme.outerRadius,
    shadow = {
      enabled = true,
    },
    blur = {
      enabled = config.theme.blur,
      size = 4,
      passes = 2,
      noise = 0.008,
      contrast = 0.8916,
      brightness = 0.8,
    },
  },
})

--[[ INPUT ]]--

hl.config({
  input = {
    kb_layout = "us",
    kb_variant = "",
    kb_model = "",
    kb_options = "gtp:alt_shift_toggle, compose:ralt",
    kb_rules = "",
    follow_mouse = 1,
    sensitivity = 0,
    touchpad = {
      natural_scroll = true,
    },
  },
})

--[[ GESTURES ]]--

-- Allow 3 finger swipe on trackpad to seek workspaces
hl.gesture({
  fingers = 3,
  direction = "horizontal",
  action = "workspace",
})

--[[ ANIMATIONS ]]--

hl.config({
  animations = {
    enabled = true,
  },
})

hl.curve("default",  { type = "bezier", points = {{0.12, 0.92}, {0.08, 1.00}} })
hl.curve("overshot", { type = "bezier", points = {{0.18, 0.95}, {0.22, 1.03}} })
hl.curve("linear",   { type = "bezier", points = {{1.00, 1.00}, {1.00, 1.00}} })

animation("windows",      5,  "default",   "popin 60%")
animation("windowsIn",    6,  "overshot",  "popin 60%")
animation("windowsOut",   4,  "overshot",  "popin 60%")
animation("windowsMove",  4,  "overshot",  "slide")
animation("layers",       4,  "default",   "popin")
animation("fadeIn",       7,  "default",   nil)
animation("fadeOut",      7,  "default",   nil)
animation("fadeSwitch",   7,  "default",   nil)
animation("fadeShadow",   7,  "default",   nil)
animation("fadeDim",      7,  "default",   nil)
animation("fadeLayers",   7,  "default",   nil)
animation("workspaces",   5,  "overshot",  "slide")
animation("border",       1,  "linear",    nil)
animation("borderangle",  24, "linear",    "loop")

--[[ LAYER RULES ]]--

-- Fix wierd borders
for _,namespace in pairs({"wofi", "notification"}) do
  hl.layer_rule({ blur = true,      match = { namespace = namespace } })
  hl.layer_rule({ ignore_alpha = 0, match = { namespace = namespace } })
end

hl.layer_rule({ no_anim = true, match = { namespace = "selection" } })

--[[ XWAYLAND ]]--

hl.config({
  xwayland = {
    force_zero_scaling = true,
    use_nearest_neighbor = false,
  },
})

--[[ HY3 ]]--

hl.config({
  general = {
    layout = "hy3",
  },
  plugin = {
    hy3 = {
      tabs = {
        height = 24,
        text_height = 9,
        text_padding = 10,
        padding = 2,
        render_text = true,
        text_font = "monospace",
        radius = config.theme.outerRadius,
        border_width = config.theme.borderWidth,
        colors = {
          active = rgb(config.theme.colors.base),
            active_border = rgb(config.theme.colors.primary),
            active_text = rgb(config.theme.colors.text),
            inactive = rgb(config.theme.colors.base),
            inactive_border = rgb(config.theme.colors.surface),
            inactive_text = rgb(config.theme.colors.text),
        }
      },
      autotile = {
        enable = true,
      },
    }
  }
})

--[[ MISC ]]--

hl.config({
  misc = {
    disable_hyprland_logo = true,
    disable_splash_rendering = true,
    key_press_enables_dpms = true,
    mouse_move_enables_dpms = true,
    enable_anr_dialog = false,
    vrr = 1,
  },
  ecosystem = {
    no_update_news = true,
    no_donation_nag = true,
  },
})

--[[ AUTOSTART ]]--

hl.on("hyprland.start", function()
  for _,app in pairs(config.autoRun) do
    hl.exec_cmd(app)
  end
end)