Files
NixOsConfig/modules/desktop/hyprland/binds.lua
T
faumaray 079cceb554 update
Signed-off-by: faumaray <faumaray@gmail.com>
2026-10-29 16:02:14 +03:00

133 lines
6.5 KiB
Lua

-- Keybindings. Shell features (launcher, panels, media keys) go through
-- Noctalia's IPC: https://docs.noctalia.dev/noctalia/ipc/
local nix = require("nixvars")
local mainMod = "SUPER"
local ipc = "noctalia msg "
-- Binds act as if the first layout (us) were active, so they also work while
-- the Russian layout is selected.
----------------------
---- APPLICATIONS ----
----------------------
-- Started through uwsm-app (nix.appLauncher), so each app is a scope of the
-- session and is stopped before the compositor at logout. The short-lived
-- commands further down (noctalia msg, screenshots) are started directly.
hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(nix.appLauncher .. " " .. nix.terminal))
hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(nix.appLauncher .. " " .. nix.fileManager))
---------------
---- WINDOWS ----
---------------
hl.bind(mainMod .. " + Q", hl.dsp.window.close())
hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen())
hl.bind(mainMod .. " + SHIFT + F", hl.dsp.window.fullscreen({ mode = "maximized" }))
hl.bind(mainMod .. " + SHIFT + Space", hl.dsp.window.float({ action = "toggle" }))
hl.bind(mainMod .. " + P", hl.dsp.window.pseudo())
hl.bind(mainMod .. " + T", hl.dsp.layout("togglesplit")) -- dwindle only
-- Emergency exit if the shell is not running.
hl.bind(mainMod .. " + SHIFT + Escape", hl.dsp.exit())
-- Move focus with mainMod + arrow keys or hjkl
hl.bind(mainMod .. " + left", hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + right", hl.dsp.focus({ direction = "right" }))
hl.bind(mainMod .. " + up", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + down", hl.dsp.focus({ direction = "down" }))
hl.bind(mainMod .. " + H", hl.dsp.focus({ direction = "left" }))
hl.bind(mainMod .. " + L", hl.dsp.focus({ direction = "right" }))
hl.bind(mainMod .. " + K", hl.dsp.focus({ direction = "up" }))
hl.bind(mainMod .. " + J", hl.dsp.focus({ direction = "down" }))
-- Move the window with mainMod + SHIFT + arrow keys or hjkl
hl.bind(mainMod .. " + SHIFT + left", hl.dsp.window.move({ direction = "left" }))
hl.bind(mainMod .. " + SHIFT + right", hl.dsp.window.move({ direction = "right" }))
hl.bind(mainMod .. " + SHIFT + up", hl.dsp.window.move({ direction = "up" }))
hl.bind(mainMod .. " + SHIFT + down", hl.dsp.window.move({ direction = "down" }))
hl.bind(mainMod .. " + SHIFT + H", hl.dsp.window.move({ direction = "left" }))
hl.bind(mainMod .. " + SHIFT + L", hl.dsp.window.move({ direction = "right" }))
hl.bind(mainMod .. " + SHIFT + K", hl.dsp.window.move({ direction = "up" }))
hl.bind(mainMod .. " + SHIFT + J", hl.dsp.window.move({ direction = "down" }))
-- Resize with mainMod + CTRL + arrow keys or hjkl
local resizeStep = 40
local resizeKeys = {
{ "left", "H", -resizeStep, 0 },
{ "right", "L", resizeStep, 0 },
{ "up", "K", 0, -resizeStep },
{ "down", "J", 0, resizeStep },
}
for _, r in ipairs(resizeKeys) do
local action = hl.dsp.window.resize({ x = r[3], y = r[4], relative = true })
hl.bind(mainMod .. " + CTRL + " .. r[1], action, { repeating = true })
hl.bind(mainMod .. " + CTRL + " .. r[2], action, { repeating = true })
end
-- Move/resize windows with mainMod + LMB/RMB and dragging
hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true })
--------------------
---- WORKSPACES ----
--------------------
-- Switch workspaces with mainMod + [0-9]
-- Move active window to a workspace with mainMod + SHIFT + [0-9]
for i = 1, 10 do
local key = i % 10 -- 10 maps to key 0
hl.bind(mainMod .. " + " .. key, hl.dsp.focus({ workspace = i }))
hl.bind(mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i }))
end
-- Scratchpad (special workspace)
hl.bind(mainMod .. " + minus", hl.dsp.workspace.toggle_special("magic"))
hl.bind(mainMod .. " + SHIFT + minus", hl.dsp.window.move({ workspace = "special:magic" }))
-- Scroll through existing workspaces with mainMod + scroll
hl.bind(mainMod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }))
hl.bind(mainMod .. " + mouse_up", hl.dsp.focus({ workspace = "e-1" }))
------------------
---- NOCTALIA ----
------------------
hl.bind(mainMod .. " + Space", hl.dsp.exec_cmd(ipc .. "panel-toggle launcher"))
hl.bind(mainMod .. " + S", hl.dsp.exec_cmd(ipc .. "panel-toggle control-center"))
hl.bind(mainMod .. " + comma", hl.dsp.exec_cmd(ipc .. "settings-toggle"))
hl.bind(mainMod .. " + V", hl.dsp.exec_cmd(ipc .. "panel-toggle clipboard"))
hl.bind(mainMod .. " + W", hl.dsp.exec_cmd(ipc .. "panel-toggle wallpaper"))
hl.bind(mainMod .. " + Escape", hl.dsp.exec_cmd(ipc .. "panel-toggle session"))
hl.bind(mainMod .. " + ALT + L", hl.dsp.exec_cmd(ipc .. "session lock"))
hl.bind("ALT + Tab", hl.dsp.exec_cmd(ipc .. "window-switcher hold"))
-- Volume, microphone, brightness and media keys
local held = { locked = true, repeating = true }
hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd(ipc .. "volume-up"), held)
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd(ipc .. "volume-down"), held)
hl.bind("XF86AudioMute", hl.dsp.exec_cmd(ipc .. "volume-mute"), held)
hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd(ipc .. "mic-mute"), held)
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd(ipc .. "brightness-up"), held)
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd(ipc .. "brightness-down"), held)
hl.bind("XF86AudioNext", hl.dsp.exec_cmd(ipc .. "media next"), { locked = true })
hl.bind("XF86AudioPause", hl.dsp.exec_cmd(ipc .. "media toggle"), { locked = true })
hl.bind("XF86AudioPlay", hl.dsp.exec_cmd(ipc .. "media toggle"), { locked = true })
hl.bind("XF86AudioPrev", hl.dsp.exec_cmd(ipc .. "media previous"), { locked = true })
---------------------
---- SCREENSHOTS ----
---------------------
-- grim + slurp, straight to the clipboard. Cancelling slurp aborts the capture.
hl.bind("Print", hl.dsp.exec_cmd('geometry=$(slurp) && grim -g "$geometry" - | wl-copy'))
hl.bind("SHIFT + Print", hl.dsp.exec_cmd("grim - | wl-copy"))
-- Region to ~/Pictures/Screenshots and the clipboard.
hl.bind("CTRL + Print", hl.dsp.exec_cmd(
'dir="$HOME/Pictures/Screenshots"; mkdir -p "$dir" && geometry=$(slurp) && ' ..
'file="$dir/$(date +%F_%H-%M-%S).png" && grim -g "$geometry" "$file" && wl-copy < "$file"'))
-- Noctalia's own region capture with the annotation editor.
hl.bind(mainMod .. " + Print", hl.dsp.exec_cmd(ipc .. "screenshot-region"))