srdusr
aboutsummaryrefslogtreecommitdiffstats
path: root/config/srd/keybindings.lua
diff options
context:
space:
mode:
authorsrdusr <[email protected]>2024-04-02 00:58:00 +0200
committersrdusr <[email protected]>2024-04-02 00:58:00 +0200
commit8110bb2773b6c841029a51eca7971f42a36f480c (patch)
treeb3b364a6c0231fe408229e94dc9e25ce4562ad02 /config/srd/keybindings.lua
parentd1f856edc516047575cf46f12fad2b59006363c8 (diff)
downloadsrdwm-8110bb2773b6c841029a51eca7971f42a36f480c.tar.gz
srdwm-8110bb2773b6c841029a51eca7971f42a36f480c.zip
Rewrite srdwm in Rust: working X11 and Wayland backends, Lua config
The C++ prototype (moved to legacy-cpp/) was mostly a design skeleton: X11 and Windows backends were partially real, Wayland created the wlroots object graph but never wired a single event listener, macOS was stub except monitor enumeration, and the Lua engine's srd.bind() stored a key-combo string but never the actual closure. See docs/PRIOR_ART.md for the full audit. This replaces it with a Cargo workspace: - srdwm-core: platform-independent window/workspace/monitor state, a real master-stack tiling layout, and SmartPlacement grid/cascade/ snap-to-edge placement - fixing several bugs in the C++ version (hardcoded 2-column grid, cascade that never cascaded, snap-to-edge that always returned a fixed rect). 35 unit tests. - srdwm-config: the srd Lua API via mlua, implementing the surface docs/DEFAULTS.md always documented but the C++ engine never actually built (srd.window.close()/focus(direction), srd.workspace.next(), real keybinding closures, require("srd") support). 10 unit tests. - srdwm-x11: a real reparenting WM with a drawn title bar (buttons, drag, resize), verified live under Xephyr - frame placement and client offset match srdwm-core's computed geometry exactly, and the decoration renders correctly on screen. - srdwm-wayland: a from-scratch smithay compositor (the C++ version had nothing working to port from) - runs via the winit backend, tracks xdg-shell toplevels through the same WindowManager and hit-testing code X11 uses, verified to start/render/run without crashing. Decorations are solid-color (no text yet); see docs/IMPLEMENTATION_STATUS.md for exact scope. - srdwm-windows / srdwm-macos: structured, cfg-gated designs informed by komorebi/glazewm and yabai/AeroSpace respectively (see docs/PRIOR_ART.md), honestly marked as unbuilt/unverified since this sandbox has no Windows or macOS target.
Diffstat (limited to 'config/srd/keybindings.lua')
-rw-r--r--config/srd/keybindings.lua215
1 files changed, 35 insertions, 180 deletions
diff --git a/config/srd/keybindings.lua b/config/srd/keybindings.lua
index e2585b2..5c05b84 100644
--- a/config/srd/keybindings.lua
+++ b/config/srd/keybindings.lua
@@ -1,185 +1,58 @@
- SRDWM Key Bindings Configuration
-- Define all keyboard shortcuts and their actions
+- Every function called here is part of the real `srd` API implemented in
+- crates/config/src/lib.rs - see docs/DEFAULTS.md for the full reference.
local srd = require("srd")
- Layout switching
-srd.bind("Mod4+1", function()
+srd.bind("Mod4+1", function()
srd.layout.set("tiling")
srd.notify("Layout: Tiling", "info")
end)
-srd.bind("Mod4+2", function()
+srd.bind("Mod4+2", function()
srd.layout.set("dynamic")
srd.notify("Layout: Dynamic", "info")
end)
-srd.bind("Mod4+3", function()
+srd.bind("Mod4+3", function()
srd.layout.set("floating")
srd.notify("Layout: Floating", "info")
end)
-- Window management
-srd.bind("Mod4+q", function()
- local window = srd.window.focused()
- if window then
- window:close()
- end
-end)
-
-srd.bind("Mod4+m", function()
- local window = srd.window.focused()
- if window then
- window:minimize()
- end
-end)
-
-srd.bind("Mod4+f", function()
- local window = srd.window.focused()
- if window then
- window:maximize()
- end
-end)
-
-- Window movement (vim-style)
-srd.bind("Mod4+h", function()
- srd.window.focus("left")
-end)
-
-srd.bind("Mod4+j", function()
- srd.window.focus("down")
-end)
-
-srd.bind("Mod4+k", function()
- srd.window.focus("up")
-end)
-
-srd.bind("Mod4+l", function()
- srd.window.focus("right")
-end)
+- Window management (act on the focused window)
+srd.bind("Mod4+q", function() srd.window.close() end)
+srd.bind("Mod4+m", function() srd.window.minimize() end)
+srd.bind("Mod4+f", function() srd.window.maximize() end)
+srd.bind("Mod4+Shift+space", function() srd.window.toggle_floating() end)
-- Window resizing
-srd.bind("Mod4+Shift+h", function()
- local window = srd.window.focused()
- if window then
- local x, y, w, h = window:get_geometry()
- window:set_geometry(x - 10, y, w + 10, h)
- end
-end)
-
-srd.bind("Mod4+Shift+j", function()
- local window = srd.window.focused()
- if window then
- local x, y, w, h = window:get_geometry()
- window:set_geometry(x, y, w, h + 10)
- end
-end)
-
-srd.bind("Mod4+Shift+k", function()
- local window = srd.window.focused()
- if window then
- local x, y, w, h = window:get_geometry()
- window:set_geometry(x, y - 10, w, h + 10)
- end
-end)
-
-srd.bind("Mod4+Shift+l", function()
- local window = srd.window.focused()
- if window then
- local x, y, w, h = window:get_geometry()
- window:set_geometry(x, y, w + 10, h)
- end
-end)
+- Window navigation (vim-style directional focus)
+srd.bind("Mod4+h", function() srd.window.focus("left") end)
+srd.bind("Mod4+j", function() srd.window.focus("down") end)
+srd.bind("Mod4+k", function() srd.window.focus("up") end)
+srd.bind("Mod4+l", function() srd.window.focus("right") end)
- Workspace management
-srd.bind("Mod4+Tab", function()
- srd.workspace.next()
-end)
+srd.bind("Mod4+Tab", function() srd.workspace.next() end)
+srd.bind("Mod4+Shift+Tab", function() srd.workspace.prev() end)
-srd.bind("Mod4+Shift+Tab", function()
- srd.workspace.prev()
-end)
-
-- Workspace switching with number keys
-for i = 1, 10 do
- srd.bind("Mod4+" .. i, function()
- srd.workspace.switch(i)
- end)
-
- srd.bind("Mod4+Shift+" .. i, function()
- local window = srd.window.focused()
- if window then
- srd.workspace.move_window(window, i)
- end
- end)
+- Workspace switching with number keys (0 doubles as "workspace 10")
+for i = 0, 9 do
+ srd.bind("Mod4+" .. i, function() srd.workspace.switch(i) end)
+ srd.bind("Mod4+Shift+" .. i, function() srd.workspace.move_window(i) end)
end
-- Monitor switching
-srd.bind("Mod4+Left", function()
- srd.monitor.focus("left")
-end)
-
-srd.bind("Mod4+Right", function()
- srd.monitor.focus("right")
-end)
-
-- Window state toggles
-srd.bind("Mod4+Shift+space", function()
- local window = srd.window.focused()
- if window then
- if window:is_floating() then
- window:set_tiling()
- else
- window:set_floating()
- end
- end
-end)
-
-srd.bind("Mod4+Shift+f", function()
- local window = srd.window.focused()
- if window then
- if window:is_fullscreen() then
- window:unset_fullscreen()
- else
- window:set_fullscreen()
- end
- end
-end)
-
- Quick actions
-srd.bind("Mod4+d", function()
- srd.spawn("rofi -show drun")
-end)
-
-srd.bind("Mod4+Return", function()
- srd.spawn("alacritty")
-end)
-
-srd.bind("Mod4+r", function()
- srd.spawn("rofi -show run")
-end)
-
-srd.bind("Mod4+w", function()
- srd.spawn("firefox")
-end)
+srd.bind("Mod4+d", function() srd.spawn("rofi -show drun") end)
+srd.bind("Mod4+Return", function() srd.spawn("alacritty") end)
+srd.bind("Mod4+r", function() srd.spawn("rofi -show run") end)
-- System actions
-srd.bind("Mod4+Shift+q", function()
- srd.quit()
-end)
+- System
+srd.bind("Mod4+Shift+q", function() srd.quit() end)
-srd.bind("Mod4+Shift+r", function()
- srd.reload_config()
-end)
-
-srd.bind("Mod4+Shift+l", function()
- srd.spawn("i3lock")
-end)
-
-- Custom functions
-function toggle_gaps()
- local current_gap = srd.get("general.window_gap")
- if current_gap > 0 then
+- Custom function example: toggle window gaps at runtime
+local function toggle_gaps()
+ if srd.get("general.window_gap") > 0 then
srd.set("general.window_gap", 0)
srd.notify("Gaps: Off", "info")
else
@@ -187,31 +60,13 @@ function toggle_gaps()
srd.notify("Gaps: On", "info")
end
end
-
srd.bind("Mod4+g", toggle_gaps)
-- Volume control
-srd.bind("XF86AudioRaiseVolume", function()
- srd.spawn("pactl set-sink-volume @DEFAULT_SINK@ +5%")
-end)
-
-srd.bind("XF86AudioLowerVolume", function()
- srd.spawn("pactl set-sink-volume @DEFAULT_SINK@ -5%")
-end)
+- Media keys
+srd.bind("XF86AudioRaiseVolume", function() srd.spawn("pactl set-sink-volume @DEFAULT_SINK@ +5%") end)
+srd.bind("XF86AudioLowerVolume", function() srd.spawn("pactl set-sink-volume @DEFAULT_SINK@ -5%") end)
+srd.bind("XF86AudioMute", function() srd.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle") end)
+srd.bind("XF86MonBrightnessUp", function() srd.spawn("brightnessctl set +5%") end)
+srd.bind("XF86MonBrightnessDown", function() srd.spawn("brightnessctl set 5%-") end)
-srd.bind("XF86AudioMute", function()
- srd.spawn("pactl set-sink-mute @DEFAULT_SINK@ toggle")
-end)
-
-- Brightness control
-srd.bind("XF86MonBrightnessUp", function()
- srd.spawn("brightnessctl set +5%")
-end)
-
-srd.bind("XF86MonBrightnessDown", function()
- srd.spawn("brightnessctl set 5%-")
-end)
-
-- Print key bindings loaded
print("Key bindings configuration loaded")
-