-- 快捷键绑定 -- mainMod = SUPER,所有组合基于 Super 键 local programs = require("conf.programs") local terminal = programs.terminal local fileManager = programs.fileManager local browser = programs.browser local mainMod = "SUPER" -- —— tide-island —— hl.bind(mainMod .. " + Tab", hl.dsp.exec_cmd("qs ipc -p /usr/share/tide-island call overview toggle"), { description = "切换预览下的窗口(tide-island)" }) -- ── 概览与窗口切换 ── hl.bind(mainMod .. " + W", function() hl.plugin.hyprexpo.expo("toggle") end, { description = "工作区概览" }) hl.bind("ALT + Tab", hl.dsp.exec_cmd("/home/atdunbg/.cargo/bin/alttabway show --next"), { description = "切换预览下的窗口" }) hl.bind("ALT + SHIFT + Tab", hl.dsp.exec_cmd("/home/atdunbg/.cargo/bin/alttabway show --prev"), { description = "切换预览上的窗口" }) -- ── 应用启动 ── hl.bind(mainMod .. " + RETURN", hl.dsp.exec_cmd(terminal), { description = "终端 (kitty)" }) hl.bind(mainMod .. " + E", hl.dsp.exec_cmd(fileManager), { description = "文件管理器 (dolphin)" }) hl.bind(mainMod .. " + R", hl.dsp.exec_cmd("qs -c noctalia-shell ipc call launcher toggle"), { description = "应用启动器 (Noctalia)" }) hl.bind(mainMod .. " + B", hl.dsp.exec_cmd(browser), { description = "浏览器 (firefox)" }) hl.bind(mainMod .. " + SLASH", hl.dsp.exec_cmd("bash -c 'if hyprctl clients -j | grep -q keymap-float; then hyprctl dispatch focuswindow keymap-float; else kitty --class keymap-float --override window_padding_width=12 --override font_size=13 /home/atdunbg/.config/hypr/scripts/keymap; fi'"), { description = "快捷键速查" }) -- ── 窗口控制 ── hl.bind(mainMod .. " + Q", hl.dsp.window.close(), { description = "关闭窗口" }) hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen({ mode = "maximized" }), { description = "最大化(保留边距)" }) hl.bind(mainMod .. " + SHIFT + F", hl.dsp.window.fullscreen(), { description = "全屏" }) hl.bind(mainMod .. " + V", hl.dsp.window.float({ action = "toggle" }), { description = "浮动/平铺切换" }) hl.bind(mainMod .. " + P", hl.dsp.window.pseudo(), { description = "伪平铺" }) hl.bind(mainMod .. " + T", hl.dsp.layout("togglesplit"), { description = "切换分割方向" }) -- 窗口调整大小(Super+Alt+H/J/K/L,支持长按重复) hl.bind(mainMod .. " + ALT + H", hl.dsp.window.resize({ x = -30, y = 0, relative = true }), { repeating = true, description = "窗口缩小(左)" }) hl.bind(mainMod .. " + ALT + L", hl.dsp.window.resize({ x = 30, y = 0, relative = true }), { repeating = true, description = "窗口扩大(右)" }) hl.bind(mainMod .. " + ALT + K", hl.dsp.window.resize({ x = 0, y = -30, relative = true }), { repeating = true, description = "窗口缩小(上)" }) hl.bind(mainMod .. " + ALT + J", hl.dsp.window.resize({ x = 0, y = 30, relative = true }), { repeating = true, description = "窗口扩大(下)" }) -- ── 布局切换(dwindle ↔ scrolling)── hl.bind(mainMod .. " + G", function() hl.config({ general = { layout = "dwindle" } }) end, { description = "切换到 dwindle 布局" }) hl.bind(mainMod .. " + SHIFT + G", function() hl.config({ general = { layout = "scrolling" } }) end, { description = "切换到 scrolling 布局" }) -- ── 焦点移动(Vim 风格 H/J/K/L)── hl.bind(mainMod .. " + H", hl.dsp.focus({ direction = "left" }), { description = "焦点左移" }) hl.bind(mainMod .. " + L", hl.dsp.focus({ direction = "right" }), { description = "焦点右移" }) hl.bind(mainMod .. " + K", hl.dsp.focus({ direction = "up" }), { description = "焦点上移" }) hl.bind(mainMod .. " + J", hl.dsp.focus({ direction = "down" }), { description = "焦点下移" }) -- Scrolling 布局专用快捷键 hl.bind(mainMod .. " + CTRL + J", hl.dsp.layout("focus l"), { description = "无限平铺: 聚焦左列" }) hl.bind(mainMod .. " + CTRL + K", hl.dsp.layout("focus r"), { description = "无限平铺: 聚焦右列" }) hl.bind(mainMod .. " + CTRL + N", hl.dsp.layout("colresize -0.1"), { description = "无限平铺: 缩小列宽" }) hl.bind(mainMod .. " + CTRL + M", hl.dsp.layout("colresize +0.1"), { description = "无限平铺: 增大列宽" }) -- ── 窗口移动(Super+Shift+H/J/K/L)── hl.bind(mainMod .. " + SHIFT + H", hl.dsp.window.move({ direction = "left" }), { description = "窗口左移" }) hl.bind(mainMod .. " + SHIFT + L", hl.dsp.window.move({ direction = "right" }), { description = "窗口右移" }) hl.bind(mainMod .. " + SHIFT + K", hl.dsp.window.move({ direction = "up" }), { description = "窗口上移" }) hl.bind(mainMod .. " + SHIFT + J", hl.dsp.window.move({ direction = "down" }), { description = "窗口下移" }) -- ── 工作区(1-10,0 代表 10)── for i = 1, 10 do local key = i % 10 hl.bind(mainMod .. " + " .. key, hl.dsp.focus({ workspace = i }), { description = "切换工作区 " .. i }) hl.bind(mainMod .. " + SHIFT + " .. key, hl.dsp.window.move({ workspace = i }), { description = "移动到工作区 " .. i }) end -- 相邻工作区 hl.bind(mainMod .. " + CTRL + LEFT", hl.dsp.focus({ workspace = "e-1" }), { description = "上一个工作区" }) hl.bind(mainMod .. " + CTRL + RIGHT", hl.dsp.focus({ workspace = "e+1" }), { description = "下一个工作区" }) -- ── 暂存区(抽屉式,Super+S 收放)── hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic"), { description = "切换暂存区" }) hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" }), { description = "移动到暂存区" }) -- ── 鼠标与滚轮 ── hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true, description = "鼠标拖动窗口" }) hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true, description = "鼠标调整大小" }) hl.bind(mainMod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }), { description = "滚轮下一个工作区" }) hl.bind(mainMod .. " + mouse_up", hl.dsp.focus({ workspace = "e-1" }), { description = "滚轮上一个工作区" }) -- ── 退出 ── hl.bind(mainMod .. " + M", hl.dsp.exit(), { description = "退出 Hyprland" }) -- ── 多媒体键(锁屏下也可用,支持长按重复)── hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1.5 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true, repeating = true, description = "音量增加 5%" }) hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"), { locked = true, repeating = true, description = "音量减少 5%" }) hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true, repeating = true, description = "切换静音" }) hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = true, description = "切换麦克风" }) -- ── 亮度 ── hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("brightnessctl s +10%"), { locked = true, repeating = true, description = "亮度增加 10%" }) hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("brightnessctl s 10%-"), { locked = true, repeating = true, description = "亮度减少 10%" }) -- ── 媒体控制 ── hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true, description = "下一曲" }) hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true, description = "播放/暂停" }) hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true, description = "播放/暂停" }) hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true, description = "上一曲" }) -- ── 截图 ── hl.bind("Print", hl.dsp.exec_cmd("/home/atdunbg/.config/hypr/scripts/screenshot full"), { locked = true, description = "全屏截图→保存文件" }) hl.bind(mainMod .. " + Print", hl.dsp.exec_cmd("/home/atdunbg/.config/hypr/scripts/screenshot area"), { locked = true, description = "区域截图→保存文件" }) hl.bind(mainMod .. " + SHIFT + Print", hl.dsp.exec_cmd("grim -g \"$(slurp)\" - | wl-copy && notify-send -a 截图 已复制到剪贴板 || notify-send -a 截图 截图失败"), { locked = true, description = "区域截图→仅剪贴板" })