summaryrefslogtreecommitdiff
path: root/keybind.lua
blob: da33d176cd8e1c04cfcaebdfbeaa5c6a5d52a46c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
-- 键绑定(对应 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
-- 注意:本构建中“纯 Lua 函数绑定”存在 bug 不会触发(dispatcher 绑定正常),
-- 因此这里改为执行脚本(脚本内用 hyprctl dispatch + Lua 语法 dispatcher 实现)
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" }))