Skip to content

Commit 0cdf5ea

Browse files
committed
refactor(hyprland): switch to lua config
hyprwm/Hyprland#13817
1 parent b5678b4 commit 0cdf5ea

10 files changed

Lines changed: 375 additions & 338 deletions

File tree

flake.lock

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
local nix = require("nix")
2+
3+
local mainMod = "ALT"
4+
5+
local directions = {
6+
h = "l",
7+
j = "d",
8+
k = "u",
9+
l = "r",
10+
}
11+
12+
local bindings = {
13+
-- TODO make it start a tmux session
14+
{ mainMod .. " + Return", hl.dsp.exec_cmd(nix.program.alacritty .. " -e " .. nix.program.tmux .. " new") },
15+
{ mainMod .. " + D", hl.dsp.exec_cmd(nix.program.rofi .. " -show drun -theme ~/.config/rofi/config.rasi") },
16+
17+
{ "SUPER + Up", hl.dsp.exec_cmd(nix.script.lock .. " -f && " .. nix.script.suspend) },
18+
{ "SUPER + Right", hl.dsp.exec_cmd(nix.script.lock) },
19+
20+
{ "CTRL + Space", hl.dsp.exec_cmd(nix.program["swaync-client"] .. " --hide-latest") },
21+
{ mainMod .. " + t", hl.dsp.exec_cmd(nix.program["swaync-client"] .. " -t") },
22+
23+
{ "Print", hl.dsp.exec_cmd(nix.script.screenshot) },
24+
{ mainMod .. " + Print", hl.dsp.exec_cmd(nix.script.screenshotEdit) },
25+
26+
{ mainMod .. " + SHIFT + Q", hl.dsp.window.close() },
27+
{ mainMod .. " + SHIFT + E", hl.dsp.exec_cmd('loginctl terminate-user ""') },
28+
{ mainMod .. " + SHIFT + P", hl.dsp.window.pin() },
29+
{ "CTRL + SHIFT + Space", hl.dsp.window.float({ action = "toggle" }) },
30+
{ mainMod .. " + f", hl.dsp.window.fullscreen({ mode = "fullscreen" }) },
31+
{ mainMod .. " + SHIFT + f", hl.dsp.window.fullscreen({ mode = "maximized" }) },
32+
33+
{ "CTRL + ALT + h", hl.dsp.focus({ workspace = "e-1" }) },
34+
{ "CTRL + ALT + l", hl.dsp.focus({ workspace = "e+1" }) },
35+
36+
{ "XF86AudioMute", hl.dsp.exec_cmd(nix.script.pipewireControl .. " togmute"), { locked = true } },
37+
{
38+
"XF86AudioMicMute",
39+
hl.dsp.exec_cmd(nix.program.pactl .. " set-source-mute @DEFAULT_SOURCE@ toggle"),
40+
{ locked = true },
41+
},
42+
{ "F4", hl.dsp.exec_cmd(nix.program.pactl .. " set-source-mute @DEFAULT_SOURCE@ toggle"), { locked = true } },
43+
{ "XF86AudioNext", hl.dsp.exec_cmd(nix.program.playerctl .. " next"), { locked = true } },
44+
{ "XF86AudioPrev", hl.dsp.exec_cmd(nix.program.playerctl .. " previous"), { locked = true } },
45+
{ "XF86AudioPause", hl.dsp.exec_cmd(nix.program.playerctl .. " play-pause"), { locked = true } },
46+
{ "switch:on:Lid Switch", hl.dsp.exec_cmd(nix.script.lock .. " -f && " .. nix.script.suspend), { locked = true } },
47+
{
48+
"XF86AudioRaiseVolume",
49+
hl.dsp.exec_cmd(nix.script.pipewireControl .. " up"),
50+
{ locked = true, repeating = true },
51+
},
52+
{
53+
"XF86AudioLowerVolume",
54+
hl.dsp.exec_cmd(nix.script.pipewireControl .. " down"),
55+
{ locked = true, repeating = true },
56+
},
57+
{
58+
"XF86MonBrightnessDown",
59+
hl.dsp.exec_cmd(nix.program.brightnessctl .. " -c backlight set 10%-"),
60+
{ locked = true, repeating = true },
61+
},
62+
{
63+
"XF86MonBrightnessUp",
64+
hl.dsp.exec_cmd(nix.program.brightnessctl .. " -c backlight set 10%+"),
65+
{ locked = true, repeating = true },
66+
},
67+
68+
{ mainMod .. " + mouse:272", hl.dsp.window.drag() },
69+
{ mainMod .. " + mouse:273", hl.dsp.window.resize() },
70+
71+
{ mainMod .. " + w", hl.dsp.group.toggle() },
72+
{ mainMod .. " + SHIFT + w", hl.dsp.window.move({ out_of_group = true }) },
73+
{ mainMod .. " + g", hl.dsp.submap("group") },
74+
{ mainMod .. " + m", hl.dsp.submap("media") },
75+
{ mainMod .. " + r", hl.dsp.submap("resize") },
76+
}
77+
78+
hl.define_submap("group", function()
79+
hl.bind(mainMod .. " + t", hl.dsp.group.lock({ action = "toggle" }))
80+
81+
hl.bind("h", hl.dsp.group.prev())
82+
hl.bind("l", hl.dsp.group.next())
83+
84+
hl.bind("escape", hl.dsp.submap("reset"))
85+
end)
86+
87+
hl.define_submap("media", function()
88+
hl.bind("h", hl.dsp.exec_cmd(nix.program.playerctl .. " previous"))
89+
hl.bind("l", hl.dsp.exec_cmd(nix.program.playerctl .. " next"))
90+
hl.bind("p", hl.dsp.exec_cmd(nix.program.playerctl .. " play-pause"))
91+
92+
hl.bind("escape", hl.dsp.submap("reset"))
93+
end)
94+
95+
hl.define_submap("resize", function()
96+
hl.bind("h", hl.dsp.window.resize({ x = -20, y = 0, relative = true }), { repeating = true })
97+
hl.bind("j", hl.dsp.window.resize({ x = 0, y = 20, relative = true }), { repeating = true })
98+
hl.bind("k", hl.dsp.window.resize({ x = 0, y = -20, relative = true }), { repeating = true })
99+
hl.bind("l", hl.dsp.window.resize({ x = 20, y = 0, relative = true }), { repeating = true })
100+
101+
for key, direction in pairs(directions) do
102+
hl.bind(mainMod .. " + " .. key, hl.dsp.workspace.move({ monitor = direction }))
103+
end
104+
105+
hl.bind("escape", hl.dsp.submap("reset"))
106+
end)
107+
108+
for key, direction in pairs(directions) do
109+
table.insert(bindings, { mainMod .. " + " .. key, hl.dsp.focus({ direction = direction }) })
110+
table.insert(bindings, { mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ direction = direction }) })
111+
end
112+
113+
for i = 1, 10 do
114+
local key = i % 10 -- 10 -> 0
115+
116+
table.insert(bindings, { mainMod .. " + " .. key, hl.dsp.focus({ workspace = i }) })
117+
table.insert(bindings, { mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i, follow = false }) })
118+
end
119+
120+
for _, binding in ipairs(bindings) do
121+
local key = binding[1]
122+
local dispatcher = binding[2]
123+
local options = binding[3] or {}
124+
125+
hl.bind(key, dispatcher, options)
126+
end
127+
128+
hl.gesture({ fingers = 4, direction = "horizontal", action = "workspace" })

homes/krapaince/programs/graphical/wms/hyprland/bindings.nix

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)