diff --git a/readme.md b/readme.md index 293cace..8b80b92 100644 --- a/readme.md +++ b/readme.md @@ -13,8 +13,6 @@ Ly is a lightweight TUI (ncurses-like) display manager for Linux and BSD. - Runtime (with default config): - xorg - xorg-xauth - - mcookie - - tput - shutdown ### Debian diff --git a/res/config.ini b/res/config.ini index caf1f47..06f434b 100644 --- a/res/config.ini +++ b/res/config.ini @@ -155,12 +155,6 @@ numlock = false # Service name (set to ly to use the provided pam config file) service_name = ly -# Terminal reset command (tput is faster) -term_reset_cmd = $PREFIX_DIRECTORY/bin/tput reset - -# Terminal restore cursor command -term_restore_cursor_cmd = $PREFIX_DIRECTORY/bin/tput cnorm - # Wayland setup command wayland_cmd = $CONFIG_DIRECTORY/ly/wsetup.sh diff --git a/src/auth.zig b/src/auth.zig index 983fea8..c0dc550 100644 --- a/src/auth.zig +++ b/src/auth.zig @@ -117,7 +117,9 @@ pub fn authenticate(config: Config, current_environment: Session.Environment, lo removeUtmpEntry(&entry); - try resetTerminal(pwd.pw_shell.?, config.term_reset_cmd); + // Take back control of the TTY + _ = interop.termbox.tb_init(); + _ = interop.termbox.tb_set_output_mode(interop.termbox.TB_OUTPUT_NORMAL); if (shared_err.readError()) |err| return err; } @@ -157,7 +159,8 @@ fn startSession( // Execute what the user requested std.posix.chdirZ(pwd.pw_dir.?) catch return error.ChangeDirectoryFailed; - try resetTerminal(pwd.pw_shell.?, config.term_reset_cmd); + // Give up control on the TTY + _ = interop.termbox.tb_shutdown(); switch (current_environment.display_server) { .wayland => try executeWaylandCmd(pwd.pw_shell.?, config.wayland_cmd, current_environment.cmd), @@ -270,17 +273,6 @@ fn loginConv( return status; } -fn resetTerminal(shell: [*:0]const u8, term_reset_cmd: [:0]const u8) !void { - const pid = try std.posix.fork(); - if (pid == 0) { - const args = [_:null]?[*:0]const u8{ shell, "-c", term_reset_cmd }; - std.posix.execveZ(shell, &args, std.c.environ) catch {}; - std.process.exit(1); - } - - _ = std.posix.waitpid(pid, 0); -} - fn getFreeDisplay() !u8 { var buf: [15]u8 = undefined; var i: u8 = 0; diff --git a/src/config/Config.zig b/src/config/Config.zig index 1680327..0726d39 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -41,8 +41,6 @@ shutdown_cmd: []const u8 = "/sbin/shutdown -a now", shutdown_key: []const u8 = "F1", sleep_cmd: ?[]const u8 = null, sleep_key: []const u8 = "F3", -term_reset_cmd: [:0]const u8 = build_options.prefix_directory ++ "/bin/tput reset", -term_restore_cursor_cmd: []const u8 = build_options.prefix_directory ++ "/bin/tput cnorm", tty: u8 = build_options.tty, vi_mode: bool = false, vi_default_mode: ViMode = .normal, diff --git a/src/config/migrator.zig b/src/config/migrator.zig index 66d4cfc..183dde9 100644 --- a/src/config/migrator.zig +++ b/src/config/migrator.zig @@ -63,7 +63,9 @@ pub fn configFieldHandler(_: std.mem.Allocator, field: ini.IniField) ?ini.IniFie std.mem.eql(u8, field.key, "max_desktop_len") or std.mem.eql(u8, field.key, "max_login_len") or std.mem.eql(u8, field.key, "max_password_len") or - std.mem.eql(u8, field.key, "mcookie_cmd")) + std.mem.eql(u8, field.key, "mcookie_cmd") or + std.mem.eql(u8, field.key, "term_reset_cmd") or + std.mem.eql(u8, field.key, "term_restore_cursor_cmd")) { // The options don't exist anymore mapped_config_fields = true; diff --git a/src/main.zig b/src/main.zig index 60f53fa..f22b1b3 100644 --- a/src/main.zig +++ b/src/main.zig @@ -712,15 +712,13 @@ pub fn main() !void { } try std.posix.tcsetattr(std.posix.STDIN_FILENO, .FLUSH, tb_termios); - if (auth_fails < config.auth_fails) { - _ = termbox.tb_clear(); - _ = termbox.tb_present(); - } + if (auth_fails < config.auth_fails) _ = termbox.tb_clear(); update = true; - var restore_cursor = std.process.Child.init(&[_][]const u8{ "/bin/sh", "-c", config.term_restore_cursor_cmd }, allocator); - _ = restore_cursor.spawnAndWait() catch .{}; + // Restore the cursor + _ = termbox.tb_set_cursor(0, 0); + _ = termbox.tb_present(); }, else => { if (!insert_mode) {