Krolyxon
Commit a83ac89

Branches

Refs →

aurora.confighyprsourcekeybinds.lua

182 lines · 8.8 KB · Lua

1---------------------
2---- KEYBINDINGS ----
3---------------------
4-- See https://wiki.hypr.land/Configuring/Basics/Binds/ for more
5
6hl.bind(mainMod .. " + Return", hl.dsp.exec_cmd(terminal))
7hl.bind(mainMod .. " + SHIFT + X", hl.dsp.window.close())
8hl.bind(mainMod .. " + SHIFT + Q", hl.dsp.exit())
9hl.bind(mainMod .. " + F", hl.dsp.window.fullscreen({ mode = "fullscreen", action = "toggle" }))
10hl.bind(mainMod .. " + SHIFT + F", hl.dsp.window.fullscreen({ mode = "maximized", action = "toggle" }))
11
12-- bind = $mainMod SHIFT, R, togglefloating,
13-- Smart Float: Toggle float -> Resize to 90% -> Center
14hl.bind(
15 mainMod .. "+ SHIFT + R",
16 hl.dsp.exec_cmd([[
17 if hyprctl activewindow | grep -q 'floating: 0'; then
18 W=$(hyprctl monitors -j | jq '.[] | select(.focused) | ((.width / .scale) * 0.9) | floor')
19 H=$(hyprctl monitors -j | jq '.[] | select(.focused) | ((.height / .scale) * 0.9) | floor')
20 hyprctl --batch "dispatch hl.dsp.window.float({action='set'}); dispatch hl.dsp.window.resize({x=${W}, y=${H}, relative=false})"
21 hyprctl dispatch "hl.dsp.window.center()"
22 else
23 hyprctl dispatch "hl.dsp.window.float({action='unset'})"
24 fi
25 ]]),
26 { description = "Smart Float" }
27)
28
29------------------
30-- Aurora Shell
31-----------------
32hl.bind(mainMod .. " + c", hl.dsp.exec_cmd("qs -c aurora ipc call shell toggle"))
33hl.bind(mainMod .. " + b", hl.dsp.exec_cmd("qs -c aurora ipc call shell bar"))
34hl.bind(mainMod .. " + SHIFT + b", hl.dsp.exec_cmd("systemctl --user restart aurora-shell"))
35
36hl.bind(mainMod .. " + R", hl.dsp.exec_cmd(menu))
37-- bind = $mainMod SHIFT, P, pseudo, # dwindle
38hl.bind(mainMod .. " + Tab", hl.dsp.window.cycle_next({ next = false }), { repeating = true })
39hl.bind(mainMod .. " + grave", hl.dsp.exec_cmd("qs -c aurora ipc call shell chars"), { description = "glyph picker" })
40hl.bind(mainMod .. " + escape", hl.dsp.exec_cmd("qs -c aurora ipc call shell power"))
41hl.bind(mainMod .. " + I", hl.dsp.exec_cmd("qs -c aurora ipc call shell settings ''"), { description = "aurora settings" })
42
43-- Applications
44hl.bind(mainMod .. " + W", hl.dsp.exec_cmd(browser))
45hl.bind("PRINT", hl.dsp.exec_cmd("qs -c aurora ipc call shell shot region"), { description = "screenshot" })
46hl.bind(mainMod .. " + SHIFT + P", hl.dsp.exec_cmd("qs -c aurora ipc call shell shot region"), { description = "screenshot" })
47hl.bind("SHIFT + PRINT", hl.dsp.exec_cmd("ocr"), { description = "ocr a region" })
48hl.bind(mainMod .. " + SHIFT + O", hl.dsp.exec_cmd("ocr"), { description = "ocr a region" })
49
50-- Music Controls
51hl.bind(mainMod .. " + m", hl.dsp.exec_cmd(terminal .. " -e zsh -i -c \"rmptui\""))
52hl.bind(mainMod .. " + SHIFT + m", hl.dsp.exec_cmd("madd </dev/null")) -- stdin is tty1 otherwise: madd would pick fzf
53hl.bind(mainMod .. " + p", hl.dsp.exec_cmd("mpc toggle"))
54hl.bind(mainMod .. " + period", hl.dsp.exec_cmd("mpc seek +10"), { repeating = true })
55hl.bind(mainMod .. " + comma", hl.dsp.exec_cmd("mpc seek -10"), { repeating = true })
56hl.bind(mainMod .. " + SHIFT + period", hl.dsp.exec_cmd("mpc next"))
57hl.bind(mainMod .. " + SHIFT + comma", hl.dsp.exec_cmd("mpc prev"))
58
59-- Swap current focused window with master
60hl.bind(mainMod .. " + space", hl.dsp.layout("swapwithmaster"))
61
62-- Resize windows with h/j/k/l
63hl.bind(mainMod .. " + h", hl.dsp.window.resize({ x = -30, y = 0, relative = true}), { repeating = true })
64hl.bind(mainMod .. " + l", hl.dsp.window.resize({ x = 30, y = 0, relative = true}), { repeating = true })
65hl.bind(mainMod .. " + k", hl.dsp.window.resize({ x = 0, y = -30, relative = true }), { repeating = true })
66hl.bind(mainMod .. " + j", hl.dsp.window.resize({ x = 0, y = 30, relative = true }), { repeating = true })
67
68-- Clipboard menu (cliphist)
69hl.bind(mainMod .. " + v", hl.dsp.exec_cmd("qs -c aurora ipc call shell clip"))
70
71-- -----------------------------------------------------
72-- Workspace switching
73-- -----------------------------------------------------
74
75local mainMod = "SUPER"
76for i = 1, smw.get_amount_of_workspaces() do
77 local n = tostring(i)
78 if n == "10" then n = "0" end -- Optional if you configured 10 workspaces: bind workspace 10 to SUPER + 0
79 -- Switch to the Nth workspace on the currently focused monitor.
80 hl.bind(mainMod .. " +" .. n, smw.workspace(n))
81 -- Move the active window to the Nth workspace on the currently focused monitor silently (no focus change).
82 hl.bind(mainMod .. " + SHIFT +" .. n, smw.move_to_workspace_silent(n))
83end
84
85-- dwm focusmon/tagmon: focus the previous/next monitor, or send the window to its visible workspace (focus stays)
86local function tagmon(dir)
87 return function()
88 local mons = hl.get_monitors()
89 local cur = hl.get_active_monitor()
90 if #mons < 2 or not cur then return end
91 table.sort(mons, function(a, b) return a.id < b.id end)
92 for i, m in ipairs(mons) do
93 if m.id == cur.id then
94 local target = mons[(i - 1 + dir) % #mons + 1]
95 if target.active_workspace then
96 hl.dispatch(hl.dsp.window.move({ workspace = tostring(target.active_workspace.id), follow = false }))
97 end
98 return
99 end
100 end
101 end
102end
103hl.bind(mainMod .. " + Left", hl.dsp.focus({ monitor = "-1" }))
104hl.bind(mainMod .. " + Right", hl.dsp.focus({ monitor = "+1" }))
105hl.bind(mainMod .. " + SHIFT + Left", tagmon(-1))
106hl.bind(mainMod .. " + SHIFT + Right", tagmon(1))
107
108-- Example special workspace (scratchpad)
109hl.bind(mainMod .. " + S", hl.dsp.workspace.toggle_special("magic"))
110hl.bind(mainMod .. " + SHIFT + S", hl.dsp.window.move({ workspace = "special:magic" }))
111
112-- Scratchpad like DWM
113hl.workspace_rule({ workspace = "special:h", on_created_empty = terminal })
114hl.bind(mainMod .. " + SHIFT + Return", hl.dsp.workspace.toggle_special("h"))
115
116-- --- Accessibility: Zoom ---
117hl.config({ cursor = { zoom_disable_aa = true } })
118
119hl.bind(
120 "SUPER + equal",
121 function()
122 local z = hl.get_config("cursor.zoom_factor")
123 hl.config({ cursor = { zoom_factor = z * 1.25 } })
124 end,
125 { description = "Zoom In", repeating = true }
126)
127
128hl.bind(
129 "SUPER + minus",
130 function()
131 local z = hl.get_config("cursor.zoom_factor")
132 local nz = z / 1.25
133 if nz < 1.0 then nz = 1.0 end
134 hl.config({ cursor = { zoom_factor = nz } })
135 end,
136 { description = "Zoom Out", repeating = true }
137)
138
139hl.bind(
140 "SUPER + BACKSPACE",
141 function()
142 hl.config({ cursor = { zoom_factor = 1.0 } })
143 end,
144 { description = "Reset Zoom", locked = true }
145)
146
147-- Screen Rotate
148hl.bind(mainMod .. " + CTRL + comma", hl.dsp.exec_cmd("hypr_screen_rotate.py +90"),
149 { locked = true, desc = "Rotate Screen Anti-Clockwise" })
150hl.bind(mainMod .. " + CTRL + period", hl.dsp.exec_cmd("hypr_screen_rotate.py -90"),
151 { locked = true, desc = "Rotate Screen Clockwise" })
152
153-- Scroll through existing workspaces with mainMod + scroll
154hl.bind(mainMod .. " + mouse_down", hl.dsp.focus({ workspace = "e+1" }))
155hl.bind(mainMod .. " + mouse_up", hl.dsp.focus({ workspace = "e-1" }))
156
157-- Move/resize windows with mainMod + LMB/RMB and dragging
158hl.bind(mainMod .. " + mouse:272", hl.dsp.window.drag(), { mouse = true })
159hl.bind(mainMod .. " + mouse:273", hl.dsp.window.resize(), { mouse = true })
160
161-- mainMod + MMB drag: float a tiled window and move it, like dwm
162-- (follow_mouse = 1, so the active window is the one under the cursor)
163hl.bind(mainMod .. " + mouse:274", function()
164 local w = hl.get_active_window()
165 if w and not w.floating then hl.dispatch(hl.dsp.window.float({ action = "set" })) end
166end, { non_consuming = true })
167hl.bind(mainMod .. " + mouse:274", hl.dsp.window.drag(), { mouse = true })
168
169-- Laptop multimedia keys for volume and LCD brightness (brightness goes through aurora for the OSD; it runs ~/.local/bin/brictl)
170hl.bind("XF86AudioRaiseVolume", hl.dsp.exec_cmd("wpctl set-volume -l 1 @DEFAULT_AUDIO_SINK@ 5%+"), { locked = true, repeating = true })
171hl.bind("XF86AudioLowerVolume", hl.dsp.exec_cmd("wpctl set-volume @DEFAULT_AUDIO_SINK@ 5%-"), { locked = true, repeating = true })
172hl.bind("XF86AudioMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SINK@ toggle"), { locked = true, repeating = true })
173hl.bind("XF86AudioMicMute", hl.dsp.exec_cmd("wpctl set-mute @DEFAULT_AUDIO_SOURCE@ toggle"), { locked = true, repeating = true })
174hl.bind("XF86MonBrightnessDown", hl.dsp.exec_cmd("qs -c aurora ipc call shell bright down"), { locked = true, repeating = true })
175hl.bind("XF86MonBrightnessUp", hl.dsp.exec_cmd("qs -c aurora ipc call shell bright up"), { locked = true, repeating = true })
176
177-- Requires playerctl
178hl.bind("XF86AudioNext", hl.dsp.exec_cmd("playerctl next"), { locked = true })
179hl.bind("XF86AudioPause", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
180hl.bind("XF86AudioPlay", hl.dsp.exec_cmd("playerctl play-pause"), { locked = true })
181hl.bind("XF86AudioPrev", hl.dsp.exec_cmd("playerctl previous"), { locked = true })
182