From 32dd0967ba9786ce8edf5e6eaaf14f865b5c24dd Mon Sep 17 00:00:00 2001 From: AnErrupTion Date: Mon, 24 Aug 2026 21:32:11 +0200 Subject: [PATCH] config: Add grab_focus_tty (closes #1039) Signed-off-by: AnErrupTion --- res/config.lua | 7 +++++++ src/config/Config.zig | 1 + src/main.zig | 5 ++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/res/config.lua b/res/config.lua index b96de8b..e0fc47a 100644 --- a/res/config.lua +++ b/res/config.lua @@ -316,6 +316,13 @@ ly = { -- Example: a string of "23" makes the cell survive on 2 or 3 neighbors gameoflife_param_survival = "23", + -- Sets the TTY on which to always grab focus on. + -- This is useful if you want to have deterministic behavior when starting + -- Ly on multiple TTYs simultaneously. + -- If null, Ly will always try to grab focus on the TTY it is launched on, + -- even if multiple instances are launched. + grab_focus_tty = nil, + -- Remove main box borders hide_borders = false, diff --git a/src/config/Config.zig b/src/config/Config.zig index ff23cad..18d4abe 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -67,6 +67,7 @@ gameoflife_frame_delay: usize = 6, gameoflife_initial_density: f32 = 0.4, gameoflife_param_birth: []const u8 = "3", gameoflife_param_survival: []const u8 = "23", +grab_focus_tty: ?u8 = null, hide_borders: bool = false, inactivity_cmd: ?[]const u8 = null, inactivity_delay: u16 = 0, diff --git a/src/main.zig b/src/main.zig index d5f728a..0bcb2db 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1007,7 +1007,10 @@ pub fn main(init: std.process.Init) !void { ); break :no_tty_found build_options.fallback_tty; }; - if (!state.use_kmscon_vt) { + if (!state.use_kmscon_vt) switch_tty: { + if (state.config.grab_focus_tty) |tty| { + if (tty != state.active_tty) break :switch_tty; + } interop.switchTty(state.active_tty) catch |err| { try state.info_line.addMessage( state.lang.err_switch_tty,