mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
cli: parse args as command when launched as 'xdg-terminal-exec'
[xdg-terminal-exec](https://github.com/Vladimir-csp/xdg-terminal-exec) is a proposal to allow users to define a "default" terminal to use when launching applications which have `Terminal=true` in their desktop file. Users can symlink their terminal of choice to `xdg-terminal-exec`, which is the first option used in the GIO launch options, and is gaining traction elsewhere. When launched as `xdg-terminal-exec`, ghostty must parse any args as the command. Add a special case using the same logic as the '-e' flag to enable ghostty to be launched in this manner. Fixes: https://github.com/mitchellh/ghostty/issues/658
This commit is contained in:
@ -1630,7 +1630,9 @@ pub fn finalize(self: *Config) !void {
|
|||||||
/// Callback for src/cli/args.zig to allow us to handle special cases
|
/// Callback for src/cli/args.zig to allow us to handle special cases
|
||||||
/// like `--help` or `-e`. Returns "false" if the CLI parsing should halt.
|
/// like `--help` or `-e`. Returns "false" if the CLI parsing should halt.
|
||||||
pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter: anytype) !bool {
|
pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter: anytype) !bool {
|
||||||
if (std.mem.eql(u8, arg, "-e")) {
|
if (std.mem.eql(u8, arg, "-e") or
|
||||||
|
std.mem.eql(u8, std.fs.path.basename(arg), "xdg-terminal-exec"))
|
||||||
|
{
|
||||||
// Build up the command. We don't clean this up because we take
|
// Build up the command. We don't clean this up because we take
|
||||||
// ownership in our allocator.
|
// ownership in our allocator.
|
||||||
var command = std.ArrayList(u8).init(alloc);
|
var command = std.ArrayList(u8).init(alloc);
|
||||||
@ -1645,8 +1647,8 @@ pub fn parseManuallyHook(self: *Config, alloc: Allocator, arg: []const u8, iter:
|
|||||||
try self._errors.add(alloc, .{
|
try self._errors.add(alloc, .{
|
||||||
.message = try std.fmt.allocPrintZ(
|
.message = try std.fmt.allocPrintZ(
|
||||||
alloc,
|
alloc,
|
||||||
"missing command after -e",
|
"missing command after {s}",
|
||||||
.{},
|
.{arg},
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user