config: Add grab_focus_tty (closes #1039)

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion 2026-08-24 21:32:11 +02:00
commit 32dd0967ba
No known key found for this signature in database
3 changed files with 12 additions and 1 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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,