Files
dotfiles/desktop/config/hypr/sjb/bindings.lua
T

246 lines
13 KiB
Lua

local terminal = "footclient"
local browser = "gtk-launch chromium.desktop"
-- Keybindings
hl.bind("SUPER + SHIFT + RETURN", hl.dsp.exec_raw(browser), { description = "Open browser" })
hl.bind("SUPER + SHIFT + B", hl.dsp.exec_raw(browser), { description = "Open browser" })
hl.bind("SUPER + RETURN", hl.dsp.exec_cmd("footclient -a terminal -T terminal"),
{ description = "Open terminal" })
hl.bind("SUPER + SHIFT + F", dispatch_focus_or_launch({
match = "strata",
cmd = "gtk-launch io.github.lgse.Strata.desktop",
}), { description = "File Manager" })
hl.bind("SUPER + CTRL + RETURN", hl.dsp.exec_cmd("gtk-launch herdr.desktop"),
{ description = "Open herdr terminal" })
hl.bind("SUPER + ALT + RETURN", hl.dsp.exec_cmd("gtk-launch tmux.desktop"),
{ description = "Open tmux terminal" })
hl.bind("SUPER + SHIFT + N", hl.dsp.exec_cmd("terminal-launcher quicknotes \"nvim +'Obsidian today'\""),
{ description = "Open Obsidian today in a centered floating window" })
hl.bind("SUPER + SHIFT + A", hl.dsp.exec_cmd("terminal-launcher agenda \"nvim +'Org agenda t'\""),
{ description = "Open Org agenda in a centered floating window" })
hl.bind("SUPER + CONTROL + A", hl.dsp.exec_cmd("terminal-launcher capture \"nvim +'Org capture t'\""),
{ description = "Open Org capture in a centered floating window" })
hl.bind("SUPER + SHIFT + I", sysinfo, { description = "Show system info" })
hl.bind("SUPER + SHIFT + Q", hl.dsp.exec_raw("ostt launch --paste"), { description = "Open ostt" })
hl.bind("F9", hl.dsp.exec_raw("ostt launch --paste"), { description = "Open ostt" })
hl.bind("SUPER + Y", toggle_master_scrolling,
{ description = "Layout: Toggle master/scrolling" })
hl.bind("SUPER + W", hl.dsp.window.close(), { description = "Window: Close" })
hl.bind("SUPER + F", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" }),
{ description = "Window: Toggle fullscreen" })
hl.bind("SUPER + CONTROL + F", hl.dsp.window.fullscreen_state({ internal = 2, client = 0, action = "toggle" }),
{ description = "Window: Toggle Tiled fullscreen" })
hl.bind("SUPER + ALT + F", hl.dsp.window.fullscreen_state({ internal = 0, client = 2, action = "toggle" }),
{ description = "Window: Toggle full width" })
hl.bind("SUPER + T", toggle_float_with_limit,
{ description = "Window: Toggle floating/tiling (max 80%)" })
hl.bind("SUPER + P", toggle_pin, { description = "Window: Toggle Pin" })
hl.bind("SUPER + left", hl.dsp.focus({ direction = "l" }), { description = "Window: Focus left" })
hl.bind("SUPER + right", hl.dsp.focus({ direction = "r" }), { description = "Window: Focus right" })
hl.bind("SUPER + up", hl.dsp.focus({ direction = "u" }), { description = "Window: Focus up" })
hl.bind("SUPER + down", hl.dsp.focus({ direction = "d" }), { description = "Window: Focus down" })
hl.bind("SUPER + H", hl.dsp.focus({ direction = "l" }), { description = "Window: Focus left" })
hl.bind("SUPER + L", hl.dsp.focus({ direction = "r" }), { description = "Window: Focus right" })
hl.bind("SUPER + K", hl.dsp.focus({ direction = "u" }), { description = "Window: Focus up" })
hl.bind("SUPER + J", hl.dsp.focus({ direction = "d" }), { description = "Window: Focus down" }) -- hl.bind("SUPER + H", hl.dsp.window.resize("left"), { repeating = true, description = "Window: Resize left" })
-- hl.bind("SUPER + z", hl.dsp.focus({ last = true }), { description = "Window: Focus last" })
hl.bind("SUPER + Z", hl.dsp.focus({ urgent_or_last = true }), { description = "Window: Focus last" })
hl.bind("SUPER + ALT + period", hl.dsp.layout("cycleprev"), { description = "Window: Swap with next" })
hl.bind("SUPER + ALT + comma", hl.dsp.layout("cyclenext"), { description = "Window: Swap with prev" })
-- hl.bind("SUPER + ALT + comma", hl.dsp.workspace.move({ monitor = "-1" }),
-- { description = "Window: Move to previous workspace and follow" })
-- hl.bind("SUPER + ALT + period", hl.dsp.workspace.move({ monitor = "+1" }),
-- { description = "Window: Move to next workspace and follow" })
-- FIX: sjb
--hl.bind("SUPER + J", hl.dsp.layout("togglesplit"), { description = "Toggle window split" })
--hl.bind("SUPER + P", hl.dsp.window.pseudo(), { description = "Pseudo window" })
hl.bind("ALT + Tab", cycle_next_window({ next = true }), { description = "Window: Cycle next" })
hl.bind("ALT + SHIFT + Tab", cycle_next_window({ next = false }), { description = "Window: Cycle prev" })
hl.bind("CONTROL + ALT + TAB", hl.dsp.focus({ monitor = "+1" }), { description = "Focus on next monitor" })
hl.bind("CONTROL + ALT + SHIFT + TAB", hl.dsp.focus({ monitor = "-1" }), { description = "Focus on previous monitor" })
hl.bind("SUPER + S", hl.dsp.workspace.toggle_special("scratchpad"), { description = "Toggle scratchpad" })
hl.bind("SUPER + ALT + S", hl.dsp.window.move({ workspace = "special:scratchpad", follow = false }),
{ description = "Move window to scratchpad" })
-- hl.bind("SUPER + TAB", hl.dsp.focus({ monitor = "+1" }), { description = "Monitor: move focus to next monitor" })
hl.bind("SUPER + TAB", hl.dsp.focus({ workspace = "e+1" }), { description = "Next workspace" })
hl.bind("SUPER + SHIFT + TAB", hl.dsp.focus({ workspace = "e-1" }), { description = "Previous workspace" })
hl.bind("SUPER + CONTROL + TAB", hl.dsp.focus({ workspace = "previous" }), { description = "Former workspace" })
hl.bind("SUPER + ALT + SHIFT + LEFT", hl.dsp.workspace.move({ monitor = "l" }),
{ description = "Move workspace to left monitor" })
hl.bind("SUPER + ALT + SHIFT + RIGHT", hl.dsp.workspace.move({ monitor = "r" }),
{ description = "Move workspace to right monitor" })
hl.bind("SUPER + ALT + SHIFT + UP", hl.dsp.workspace.move({ monitor = "u" }),
{ description = "Move workspace to up monitor" })
hl.bind("SUPER + ALT + SHIFT + DOWN", hl.dsp.workspace.move({ monitor = "d" }),
{ description = "Move workspace to down monitor" })
hl.bind("SUPER + SHIFT + LEFT", hl.dsp.window.swap({ direction = "l" }), { description = "Swap window to the left" })
hl.bind("SUPER + SHIFT + RIGHT", hl.dsp.window.swap({ direction = "r" }), { description = "Swap window to the right" })
hl.bind("SUPER + SHIFT + UP", hl.dsp.window.swap({ direction = "u" }), { description = "Swap window up" })
hl.bind("SUPER + SHIFT + DOWN", hl.dsp.window.swap({ direction = "d" }), { description = "Swap window down" })
hl.bind("SUPER + ALT + Tab", hl.dsp.focus({ workspace = "next", on_current_monitor = true }),
{ description = "Window: Focus previous in workspace" })
hl.bind("SUPER + ALT + SHIFT + Tab", hl.dsp.focus({ workspace = "previous", on_current_monitor = true }),
{ description = "Window: Focus previous in workspace" })
-- arrange split ratio
hl.bind("SUPER + SHIFT + M", toggle_master, { description = "Layout: Toggle master size" })
hl.bind("SUPER + M", function()
local current_layout = hl.get_config("general.layout")
if current_layout == "master" then
hl.dispatch(hl.dsp.layout("swapwithmaster"))
end
if current_layout == "scrolling" then
hl.dispatch(hl.dsp.layout("consume_or_expel next"))
end
end, { description = "Layout: Swap with master" })
hl.bind("SUPER + period", function()
local current_layout = hl.get_config("general.layout")
if current_layout == "master" then
hl.dispatch(hl.dsp.layout("cycleprev"))
hl.dispatch(hl.dsp.layout("swapwithmaster"))
end
if current_layout == "scrolling" then
hl.dispatch(hl.dsp.layout("swapcol r"))
hl.dispatch(hl.dsp.layout("focus l"))
end
-- hl.dispatch(hl.dsp.layout("focus r"))
end, { description = "Layout: Cycle next" })
hl.bind("SUPER + comma", function()
local current_layout = hl.get_config("general.layout")
if current_layout == "master" then
hl.dispatch(hl.dsp.layout("cyclenext"))
hl.dispatch(hl.dsp.layout("swapwithmaster"))
end
if current_layout == "scrolling" then
hl.dispatch(hl.dsp.layout("swapcol l"))
hl.dispatch(hl.dsp.layout("focus r"))
end
-- hl.dispatch(hl.dsp.layout("focus l"))
end, { description = "Layout: Cycle previous" })
hl.bind("SUPER + SHIFT + comma", hl.dsp.window.move({ workspace = "-1" }),
{ description = "Window: Move to previous workspace" })
hl.bind("SUPER + SHIFT + period", hl.dsp.window.move({ workspace = "+1" }),
{ description = "Window: Move to next workspace" })
hl.bind("SUPER + CONTROL + SHIFT + slash",
hl.dsp.exec_cmd("makoctl mode -t do-not-disturb"),
{ description = "Toggle do-not-disturb" })
hl.bind("SUPER + CONTROL + Delete", hl.dsp.exec_cmd("hyprland-toggle-monitor eDP-1"),
{ description = "Toggle laptop display" })
hl.on("keybinds.submap", function(name)
if name == "" then
hl.notification.create({ text = "Exited submap", duration = 2000, icon = "hint" })
return
end
hl.notification.create({ text = "Entered submap: " .. name, duration = 2000, icon = "hint" })
end)
hl.bind("SUPER + F9", hl.dsp.submap("resize"), { description = "Resize Menu" })
hl.define_submap("resize", function()
hl.bind("period", hl.dsp.window.resize({ x = 10, y = 10, relative = true }),
{ repeating = true, description = "Resize: Increase" })
hl.bind("comma", hl.dsp.window.resize({ x = -10, y = -10, relative = true }),
{ repeating = true, description = "Resize: Decrease" })
hl.bind("R", function()
window_resize_percentage(0.5, 0.5)
end, { description = "Resize: Reset" })
hl.bind("S", function()
window_resize_percentage(0.25, 0.25)
end, { description = "Resize: Small" })
hl.bind("D", function()
window_resize_percentage(0.7, 0.96)
hl.dispatch(hl.dsp.window.center())
end, { description = "Resize: Large" })
hl.bind("C", hl.dsp.window.center(), { description = "Resize: Center" })
hl.bind("P", hl.dsp.window.pin(), { description = "Resize: Pin" })
hl.bind("up", hl.dsp.window.move({ direction = "up" }), { description = "Resize: Move up" })
hl.bind("down", hl.dsp.window.move({ direction = "down" }), { description = "Resize: Move down" })
hl.bind("left", hl.dsp.window.move({ direction = "left" }), { description = "Resize: Move left" })
hl.bind("right", hl.dsp.window.move({ direction = "right" }), { description = "Resize: Move right" })
hl.bind("escape", hl.dsp.submap("reset"), { description = "Resize: Exit" })
hl.bind("catchall", hl.dsp.submap("reset"), { description = "Resize: Exit" })
end)
local workspaceGroupSize = 10
local numberkey = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }
function workspace_in_group(i)
local curr = hl.get_active_workspace().id
local newVal = math.floor((curr - 1) / workspaceGroupSize) * workspaceGroupSize + i
return newVal
end
for i = 1, 10 do
hl.bind("SUPER + CONTROL + code:" .. numberkey[i], function()
hl.dispatch(hl.dsp.workspace.move({ monitor = "+1", workspace = workspace_in_group(i), follow = true }))
end, { description = "Workspace: Move monitor " .. i })
end
for i = 1, 10 do
hl.bind("SUPER + SHIFT + code:" .. numberkey[i], function()
hl.dispatch(hl.dsp.window.move({ workspace = workspace_in_group(i), follow = true }))
end, { description = "Workspace: Move " .. i })
end
for i = 1, 10 do
hl.bind("SUPER + code:" .. numberkey[i], function()
hl.dispatch(hl.dsp.focus({ workspace = workspace_in_group(i), on_current_monitor = true }))
end, { description = "Workspace: Focus " .. i })
end
-- Scroll through existing workspaces with mainMod + scroll
hl.bind("SUPER + mouse_down", hl.dsp.focus({ workspace = "e+1" }), { description = "Workspace: Next" })
hl.bind("SUPER + mouse_up", hl.dsp.focus({ workspace = "e-1" }), { description = "Workspace: Previous" })
-- Move/resize windows with mainMod + LMB/RMB and dragging
hl.bind("SUPER + mouse:272", hl.dsp.window.drag(), { mouse = true, description = "Window: Drag" })
hl.bind("SUPER + mouse:273", hl.dsp.window.resize(), { mouse = true, description = "Window: Resize" })
hl.bind("mouse:275", hl.dsp.window.cycle_next({ next = true }), { click = true, description = "Window: Cycle next" })
hl.bind("mouse:276", hl.dsp.window.cycle_next({ next = false }), { click = true, description = "Window: Cycle previous" })
hl.bind(sjb.HYPR .. "semicolon", hl.dsp.exec_cmd("~/.local/bin/set-wallpaper.sh categories/technics"),
{ description = "get new wallpaper" })
-- Gestures
-- hl.gesture({ fingers = 3, direction = "horizontal", action = "workspace" })
-- hl.gesture({ fingers = 3, direction = "down", mods = "ALT", action = "close" })
-- hl.gesture({ fingers = 3, direction = "up", mods = "SUPER", scale = 1.5, action = "fullscreen" })
-- hl.gesture({ fingers = 3, direction = "left", scale = 1.5, action = "float" })
--
-- hl.gesture({ fingers = 2, direction = "pinch", action = "cursorZoom", zoom_level = 2 })
-- hl.gesture({ fingers = 2, direction = "pinch", action = "cursorZoom", zoom_level = 1.2, mode = "mult" })
-- hl.gesture({ fingers = 2, direction = "pinch", action = "cursorZoom", zoom_level = 1, mode = "live" })