git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commitff6b028084d703729176f24f23aa389ba6abe2a8
parent1b6955179d
authorIsaac Freund <[email protected]>
date2025-12-01 13:08
river: ctrl+alt+delete to exit

Will probably change this to drop into the "fallback" wm instead if that
idea works out in the long term.

 river/KeyboardGroup.zig | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/river/KeyboardGroup.zig b/river/KeyboardGroup.zig
index 8dd2c4d..23ab6fa 100644
--- a/river/KeyboardGroup.zig
+++ b/river/KeyboardGroup.zig
@@ -194,13 +194,13 @@ fn handleKey(listener: *wl.Listener(*wlr.Keyboard.event.Key), event: *wlr.Keyboa
         }
         // Translate libinput keycode -> xkbcommon
         const xkb_keycode = event.keycode + 8;
+        const modifiers = group.state.getModifiers();
         for (xkb_state.keyGetSyms(xkb_keycode)) |sym| {
-            if (handleBuiltinBinding(sym)) {
+            if (handleBuiltinBinding(sym, modifiers)) {
                 log.debug("matched builtin binding", .{});
                 break :blk .builtin;
             }
         }
-        const modifiers = group.state.getModifiers();
         if (group.seat.matchXkbBinding(xkb_keycode, modifiers, xkb_state)) |binding| {
             log.debug("matched xkb binding", .{});
             break :blk .{
@@ -257,7 +257,7 @@ fn handleModifiers(listener: *wl.Listener(*wlr.Keyboard), _: *wlr.Keyboard) void
 
 /// Handle any builtin, hardcoded compositor keybindings such as VT switching.
 /// Returns true if the keysym was handled.
-fn handleBuiltinBinding(keysym: xkb.Keysym) bool {
+fn handleBuiltinBinding(keysym: xkb.Keysym, modifiers: wlr.Keyboard.ModifierMask) bool {
     switch (@intFromEnum(keysym)) {
         xkb.Keysym.XF86Switch_VT_1...xkb.Keysym.XF86Switch_VT_12 => {
             log.debug("switch VT keysym received", .{});
@@ -268,6 +268,15 @@ fn handleBuiltinBinding(keysym: xkb.Keysym) bool {
             }
             return true;
         },
+        xkb.Keysym.Delete => {
+            if (modifiers == wlr.Keyboard.ModifierMask{ .ctrl = true, .alt = true }) {
+                log.debug("ctrl+alt+delete pressed, exiting...", .{});
+                server.wl_server.terminate();
+                return true;
+            } else {
+                return false;
+            }
+        },
         else => return false,
     }
 }