summaryrefslogtreecommitdiff
path: root/keybind.lua
diff options
context:
space:
mode:
Diffstat (limited to 'keybind.lua')
-rw-r--r--keybind.lua102
1 files changed, 102 insertions, 0 deletions
diff --git a/keybind.lua b/keybind.lua
new file mode 100644
index 0000000..c0e765b
--- /dev/null
+++ b/keybind.lua
@@ -0,0 +1,102 @@
+-- 键绑定(对应 keybind.conf)
+-- 参考 https://wiki.hypr.land/Configuring/Basics/Binds/
+-- 在 Lua 中,键绑定通过 hl.bind(按键, 动作) 声明
+
+local variables = require("variables")
+
+local mainMod = "ALT" -- 将 "ALT" 键设置为主修饰键
+
+-- 打开终端 ALT + F2
+hl.bind(mainMod .. " + F2", hl.dsp.exec_cmd(variables.terminal))
+
+-- 打开文件管理器 ALT + CTRL + F
+hl.bind(mainMod .. " + CTRL + F", hl.dsp.exec_cmd(variables.fileManager))
+
+-- 退出当前程序 ALT + F4
+hl.bind(mainMod .. " + F4", hl.dsp.window.kill())
+
+-- 搜索文件 CTRL ALT + Q
+hl.bind(mainMod .. " + CTRL + Q", hl.dsp.exec_cmd("flatpak run io.github.cboxdoerfer.FSearch"))
+
+-- 截图 CTRL + ALT + A
+hl.bind(mainMod .. " + CTRL + A", hl.dsp.exec_cmd(variables.screenshot))
+
+-- 退出程序 ALT + SHIFT + F12
+hl.bind(mainMod .. " + SHIFT + F12", hl.dsp.exit())
+
+-- 切换浮动窗口 ALT + F
+-- hl.bind(mainMod .. " + F", hl.dsp.window.float())
+hl.bind(mainMod .. " + F", hl.dsp.exec_cmd("~/.config/hypr/scripts/toggle_float_center.sh"))
+
+-- 切换全屏 ALT + F12
+hl.bind(mainMod .. " + F12", hl.dsp.window.fullscreen())
+
+-- 显示应用菜单 ALT + SPACE
+hl.bind(mainMod .. " + space", hl.dsp.exec_cmd(variables.menu))
+
+-- 切换窗口平铺模式 ALT + O/P
+hl.bind(mainMod .. " + O", hl.dsp.window.pseudo()) -- dwindle
+hl.bind(mainMod .. " + P", hl.dsp.layout("togglesplit")) -- dwindle
+
+-- 系统监视器 CTRL SHIFT + ESC
+hl.bind("CTRL + SHIFT + escape", hl.dsp.exec_cmd(variables.systemMonitor))
+hl.bind(mainMod .. " + F5", hl.dsp.exec_cmd("hyprctl reload"))
+
+-- 剪贴板历史 SUPER + V
+hl.bind("SUPER + V", hl.dsp.exec_cmd(variables.clipboardManager))
+
+-- 移动焦点 ALT + 方向
+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" }))
+
+-- 移动窗口 ALT + CTRL + 方向
+hl.bind(mainMod .. " + CTRL + left", hl.dsp.window.move({ direction = "left" }))
+hl.bind(mainMod .. " + CTRL + right", hl.dsp.window.move({ direction = "right" }))
+hl.bind(mainMod .. " + CTRL + up", hl.dsp.window.move({ direction = "up" }))
+hl.bind(mainMod .. " + CTRL + down", hl.dsp.window.move({ direction = "down" }))
+
+-- 切换工作区 SUPER + ALT + 左/右
+hl.bind(mainMod .. " + SUPER + left", hl.dsp.focus({ workspace = "-1" }))
+hl.bind(mainMod .. " + SUPER + right", hl.dsp.focus({ workspace = "+1" }))
+-- hl.bind(mainMod .. " + SUPER + left", hl.dsp.layout("move -col"))
+-- hl.bind(mainMod .. " + SUPER + right", hl.dsp.layout("move +col"))
+
+-- 总览 SUPER + ALT + 上/下
+-- hl.bind(mainMod .. " + SUPER + up", hl.dsp.event("overview:toggle"))
+-- hl.bind(mainMod .. " + SUPER + down", hl.dsp.event("overview:close"))
+
+-- 示例特殊工作区(便签簿) SUPER + ALT + 上
+hl.bind(mainMod .. " + SUPER + up", hl.dsp.workspace.toggle_special("magic"))
+
+-- 浏览现有工作区 ALT + 滚轮
+-- hl.bind(mainMod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }))
+-- hl.bind(mainMod .. " + mouse_up", hl.dsp.focus({ workspace = "e-1" }))
+
+-- 使用 ALT + 左键/右键 点击并拖动来移动/调整窗口大小(bindm)
+hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
+hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true })
+
+-- 笔记本电脑多媒体键,用于音量和 LCD 亮度(bindel)
+hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true, repeating = true })
+hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"), { locked = true, repeating = true })
+hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true, repeating = true })
+hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = 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 })
+
+-- 需要 playerctl(bindl)
+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 })
+
+-- 移动窗口至其他工作区(CTRL + ALT + 数字)
+for i = 1, 10 do
+ local key = i % 10 -- 10 映射到按键 0
+ hl.bind("CTRL + " .. mainMod .. " + " .. key, hl.dsp.window.move({ workspace = tostring(i) }))
+end
+
+-- 移动窗口至特殊工作区(CTRL + ALT + 下)
+hl.bind("CTRL + " .. mainMod .. " + down", hl.dsp.window.move({ workspace = "special:magic" }))