repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

hypr/modules/binds.lua

Raw
local apps = require("lib.apps")
local workspaces = require("modules.workspaces")
local mod = "SUPER"

local function bind(key, cmd, description)
  hl.bind(key, hl.dsp.exec_cmd(cmd), { description = description })
end

bind(mod .. " + Return", apps.terminal, "terminal: wezterm")
bind(mod .. " + Space", apps.launcher, "launcher: hyprlauncher")
bind(mod .. " + B", apps.browser, "browser: firefox")
bind(mod .. " + E", apps.file_manager, "file manager: yazi")
hl.bind(mod .. " + Q", hl.dsp.window.close(), { description = "close window" })
hl.bind(mod .. " + C", hl.dsp.window.close(), { description = "close window" })
bind(mod .. " + V", apps.clipboard, "clipboard history")
bind(mod .. " + ALT + L", apps.lock, "lock")
bind(mod .. " + ALT + S", "loginctl lock-session && systemctl suspend", "lock + suspend")
bind(mod .. " + SHIFT + R", "hyprctl reload", "reload hypr")
bind(mod .. " + SHIFT + T", apps.theme_toggle, "toggle nugu light/dark")
bind(mod .. " + CTRL + T", apps.theme_auto, "nugu auto mode now")
bind(mod .. " + Slash", apps.binds_help, "show binds")
bind(mod .. " + Tab", apps.clients_help, "show clients")
bind(mod .. " + Escape", "makoctl dismiss --all", "dismiss notifications")
bind("CTRL + ALT + Delete", apps.logout, "graceful hyprland logout")

hl.bind(mod .. " + H", hl.dsp.focus({ direction = "left" }), { description = "focus left" })
hl.bind(mod .. " + L", hl.dsp.focus({ direction = "right" }), { description = "focus right" })
hl.bind(mod .. " + K", hl.dsp.focus({ direction = "up" }), { description = "focus up" })
hl.bind(mod .. " + J", hl.dsp.focus({ direction = "down" }), { description = "focus down" })

hl.bind(mod .. " + SHIFT + H", hl.dsp.window.move({ direction = "left" }), { description = "move left" })
hl.bind(mod .. " + SHIFT + L", hl.dsp.window.move({ direction = "right" }), { description = "move right" })
hl.bind(mod .. " + SHIFT + K", hl.dsp.window.move({ direction = "up" }), { description = "move up" })
hl.bind(mod .. " + SHIFT + J", hl.dsp.window.move({ direction = "down" }), { description = "move down" })

hl.bind(mod .. " + CTRL + H", hl.dsp.window.resize({ x = -24, y = 0, relative = true }), { description = "resize left" })
hl.bind(mod .. " + CTRL + L", hl.dsp.window.resize({ x = 24, y = 0, relative = true }), { description = "resize right" })
hl.bind(mod .. " + CTRL + K", hl.dsp.window.resize({ x = 0, y = -24, relative = true }), { description = "resize up" })
hl.bind(mod .. " + CTRL + J", hl.dsp.window.resize({ x = 0, y = 24, relative = true }), { description = "resize down" })

hl.bind(mod .. " + F", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" }), { description = "fullscreen" })
hl.bind(mod .. " + T", hl.dsp.window.float({ action = "toggle" }), { description = "toggle floating" })
hl.bind(mod .. " + P", hl.dsp.window.pseudo({ action = "toggle" }), { description = "pseudo tile" })
hl.bind(mod .. " + G", hl.dsp.group.toggle(), { description = "toggle group" })
hl.bind(mod .. " + SHIFT + G", hl.dsp.group.next(), { description = "next group tab" })

for _, ws in ipairs(workspaces.list) do
  local target = "name:" .. ws.name
  hl.bind(mod .. " + " .. ws.key, hl.dsp.focus({ workspace = target }), { description = "workspace " .. ws.name })
  hl.bind(mod .. " + SHIFT + " .. ws.key, hl.dsp.window.move({ workspace = target }), { description = "move to " .. ws.name })
end

hl.bind(mod .. " + S", hl.dsp.workspace.toggle_special("scratch"), { description = "toggle scratch" })
hl.bind(mod .. " + SHIFT + V", hl.dsp.window.move({ workspace = "special:scratch" }), { description = "send to scratch" })
hl.bind(mod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }))
hl.bind(mod .. " + mouse_up", hl.dsp.focus({ workspace = "e-1" }))
hl.bind(mod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true, description = "drag window" })
hl.bind(mod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true, description = "resize window" })

hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 2%+"), { locked = true, repeating = true })
hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 2%-"), { locked = true, repeating = true })
hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true })
hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true })
hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%+"), { locked = true, repeating = true })
hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl -e4 -n2 set 5%-"), { locked = true, repeating = true })
hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true })
hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true })

bind("Print", apps.screenshot_region, "screenshot region")
bind("SHIFT + Print", apps.screenshot_window, "screenshot window")
bind("CTRL + Print", apps.screenshot_output, "screenshot output")
bind(mod .. " + Print", apps.screenshot_annotate, "screenshot annotate")
bind(mod .. " + SHIFT + Print", "hyprpicker -a", "pick color")