Use Lua instead of Chezmoi templates for per layout keybindings
This commit is contained in:
parent
66bb8a296e
commit
f7cae059be
1 changed files with 40 additions and 23 deletions
|
|
@ -257,6 +257,20 @@ hl.permission({ binary = "/usr/(lib|libexec|lib64)/xdg-desktop-portal-hyprland",
|
|||
|
||||
-- https://wiki.hypr.land/Configuring/Basics/Binds
|
||||
|
||||
-- https://wiki.hypr.land/Configuring/Advanced-and-Cool/Uncommon-tips-and-tricks/#per-layout-bindings
|
||||
local function layout_bind(bind_table)
|
||||
return function ()
|
||||
local workspace = hl.get_active_special_workspace() or hl.get_active_workspace()
|
||||
if not workspace then
|
||||
return
|
||||
end
|
||||
local layout = workspace.tiled_layout
|
||||
if bind_table[layout] then
|
||||
hl.dispatch(bind_table[layout])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hl.bind("SUPER + RETURN", hl.dsp.exec_cmd(terminal))
|
||||
hl.bind("SUPER + Q", hl.dsp.exec_cmd(browser))
|
||||
hl.bind("SUPER + W", hl.dsp.window.close())
|
||||
|
|
@ -279,15 +293,32 @@ hl.dsp.exec_cmd("pkill fuzzel || bluetoothctl -- connect \"$(bluetoothctl -- dev
|
|||
hl.bind("SUPER + SHIFT + A", hl.dsp.exec_cmd("sh ~/scripts/select-audio-sink.sh"))
|
||||
|
||||
-- Move focus
|
||||
{{- if eq .hyprlandLayout "dwindle" }}
|
||||
hl.bind("SUPER + H", hl.dsp.focus({ direction = "left" }))
|
||||
hl.bind("SUPER + L", hl.dsp.focus({ direction = "right" }))
|
||||
hl.bind("SUPER + J", hl.dsp.focus({ direction = "down" }))
|
||||
hl.bind("SUPER + K", hl.dsp.focus({ direction = "up" }))
|
||||
{{- else if eq .hyprlandLayout "scrolling" }}
|
||||
hl.bind("SUPER + H", hl.dsp.layout("move -col"))
|
||||
hl.bind("SUPER + L", hl.dsp.layout("move +col"))
|
||||
{{- end }}
|
||||
hl.bind("SUPER + H", layout_bind({
|
||||
dwindle = hl.dsp.focus({ direction = "left" }),
|
||||
scrolling = hl.dsp.layout("move -col")
|
||||
}))
|
||||
hl.bind("SUPER + L", layout_bind({
|
||||
dwindle = hl.dsp.focus({ direction = "right" }),
|
||||
scrolling = hl.dsp.layout("move +col")
|
||||
}))
|
||||
hl.bind("SUPER + J", layout_bind({
|
||||
dwindle = hl.dsp.focus({ direction = "down" }),
|
||||
scrolling = hl.dsp.layout("colresize -conf")
|
||||
}))
|
||||
hl.bind("SUPER + K", layout_bind({
|
||||
dwindle = hl.dsp.focus({ direction = "up" }),
|
||||
scrolling = hl.dsp.layout("colresize +conf")
|
||||
}))
|
||||
|
||||
-- Move/resize windows
|
||||
hl.bind("SUPER + mouse:272", hl.dsp.window.drag(), { mouse = true })
|
||||
hl.bind("SUPER + mouse:273", hl.dsp.window.resize(), { mouse = true })
|
||||
hl.bind("SUPER + SHIFT + H", layout_bind({ scrolling = hl.dsp.layout("swapcol l") }))
|
||||
hl.bind("SUPER + SHIFT + L", layout_bind({ scrolling = hl.dsp.layout("swapcol r") }))
|
||||
hl.bind("SUPER + SHIFT + J", layout_bind({ scrolling = hl.dsp.layout("colresize -0.1") }))
|
||||
hl.bind("SUPER + SHIFT + K", layout_bind({ scrolling = hl.dsp.layout("colresize +0.1") }))
|
||||
|
||||
hl.bind("SUPER + ALT + P", hl.dsp.window.pin())
|
||||
|
||||
for i = 1, 10 do
|
||||
local key = i % 10 -- 10 maps to key 0
|
||||
|
|
@ -299,20 +330,6 @@ end
|
|||
|
||||
hl.bind("SUPER + SHIFT + CTRL + TAB", hl.dsp.workspace.move({ monitor = "+1" }))
|
||||
|
||||
-- Move/resize windows
|
||||
hl.bind("SUPER + mouse:272", hl.dsp.window.drag(), { mouse = true })
|
||||
hl.bind("SUPER + mouse:273", hl.dsp.window.resize(), { mouse = true })
|
||||
{{- if eq .hyprlandLayout "scrolling" }}
|
||||
hl.bind("SUPER + SHIFT + H", hl.dsp.layout("swapcol l"))
|
||||
hl.bind("SUPER + SHIFT + L", hl.dsp.layout("swapcol r"))
|
||||
hl.bind("SUPER + J", hl.dsp.layout("colresize -conf"))
|
||||
hl.bind("SUPER + SHIFT + J", hl.dsp.layout("colresize -0.1"))
|
||||
hl.bind("SUPER + K", hl.dsp.layout("colresize +conf"))
|
||||
hl.bind("SUPER + SHIFT + K", hl.dsp.layout("colresize +0.1"))
|
||||
{{- end }}
|
||||
|
||||
hl.bind("SUPER + ALT + P", hl.dsp.window.pin())
|
||||
|
||||
-- Laptop multimedia keys for volume and LCD brightness
|
||||
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%+ && ~/scripts/volume-control.sh"), { locked = true, repeating = true })
|
||||
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%- && ~/scripts/volume-control.sh"), { locked = true, repeating = true })
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue