From 306e9f8bb692a8aa0b4b3ec09307b844152d3c19 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Wed, 17 Jul 2024 11:17:15 -0700 Subject: [PATCH] config: `-e` CLI flag automatically implies `gtk-single-instance=false` `gtk-single-instance` should already be doing desktop-only detection and in most cases it does. But there are some cases where it isn't and we haven't quite tracked it down yet. In any case, when `-e` is used from the CLI, we definitely do not want to launch in single instance mode because `-e` is typically used in scripts or for one-off instances. This forces gtk-single-instance to false. --- src/config/Config.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/config/Config.zig b/src/config/Config.zig index 6f780bb33..d712a56eb 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -432,7 +432,9 @@ palette: Palette = .{}, /// /// If you're using the `ghostty` CLI there is also a shortcut to run a command /// with arguments directly: you can use the `-e` flag. For example: `ghostty -e -/// fish --with --custom --args`. +/// fish --with --custom --args`. The `-e` flag also automatically sets +/// `gtk-single-instance = false` (no matter what) to ensure that a new +/// instance is launched and the CLI args are respected. command: ?[]const u8 = null, /// If true, keep the terminal open after the command exits. Normally, the @@ -2095,6 +2097,11 @@ pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter: self.command = command.items[0 .. command.items.len - 1]; + // When "-e" is used on the command line then we always disabled + // single instance mode because single instance mode is incompatible + // with CLI flags. + self.@"gtk-single-instance" = .false; + // Do not continue, we consumed everything. return false; }