diff --git a/src/interop.zig b/src/interop.zig index a053747..5c017bb 100644 --- a/src/interop.zig +++ b/src/interop.zig @@ -6,6 +6,10 @@ pub const termbox = @cImport({ @cInclude("termbox.h"); }); +pub const vt = @cImport({ + @cInclude("linux/vt.h"); +}); + pub const pam = @cImport({ @cInclude("security/pam_appl.h"); }); @@ -44,6 +48,7 @@ pub const passwd = extern struct { pw_shell: [*:0]u8, }; +pub const VT_GETSTATE: c_int = 0x5603; pub const VT_ACTIVATE: c_int = 0x5606; pub const VT_WAITACTIVE: c_int = 0x5607; diff --git a/src/main.zig b/src/main.zig index bff277b..2d16db5 100644 --- a/src/main.zig +++ b/src/main.zig @@ -526,6 +526,11 @@ pub fn main() !void { defer shared_err.deinit(); { + // This will set the current active VT as our TTY. + var vtstat: interop.vt.vt_stat = undefined; + _ = std.c.ioctl(std.c.STDIN_FILENO, interop.VT_GETSTATE, &vtstat); + config.tty = @intCast(vtstat.v_active); + const login_text = try allocator.dupeZ(u8, login.text.items); defer allocator.free(login_text); const password_text = try allocator.dupeZ(u8, password.text.items);