we can now switch vts

This commit is contained in:
Squibid 2025-10-26 12:53:44 -04:00
parent 976900ffa6
commit 591aa73bed
2 changed files with 23 additions and 0 deletions

View file

@ -35,6 +35,12 @@ mez.input.add_keymap("alt", "q", {
end
})
for i = 1, 12 do
mez.input.add_keymap("ctrl|alt", "XF86Switch_VT_"..i, {
press = function() mez.api.chvt(i) end
})
end
-- mez.input.add_keymap("alt", "a", {
-- press = function()
-- print("hello from my keymap")

View file

@ -1,5 +1,6 @@
const std = @import("std");
const zlua = @import("zlua");
const wlr = @import("wlroots");
const gpa = std.heap.c_allocator;
@ -57,3 +58,19 @@ pub fn exit(L: *zlua.Lua) i32 {
return 0;
}
pub fn chvt(L: *zlua.Lua) i32 {
L.checkType(1, .number);
const f = L.toNumber(-1) catch unreachable;
const n: u32 = @intFromFloat(f);
if (server.session) |session| {
wlr.Session.changeVt(session, n) catch {
L.raiseErrorStr("Failed to switch vt", .{});
};
} else {
L.raiseErrorStr("Mez has not been initialized yet", .{});
}
return 0;
}