aboutsummaryrefslogtreecommitdiff
path: root/client-protocol.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2026-11-12 10:50:55 +0000
committerDaniel Eklöf <daniel@ekloef.se>2026-11-12 11:01:00 +0000
commitf51f18d33557ea9078f7781f4a4235706228f5c9 (patch)
tree7d518d3abac3ecc8bf2e38518c7c5ecbb6ee40a9 /client-protocol.h
parentime: reset view & cancel selection on text commit (diff)
spawn-terminal: spawn with all the original command line optionsspawn-terminal-cmdline-arguments
Before this, spawn-terminal would spawn a new foot or footclient, but *without* any of the command line options the user started the original foot/footclient with. We did have a hack for --config, but all other options were forgotten in the new instance. This patch fixes this. * term_init() stores the raw argc/argv in the terminal struct. * term_spawn_new() calls spawn() with the stored argc/argv. * for single instances, main() calls term_init() with the unparsed argc/argv. * the client/server protocol is extended to always send the raw argc/argv to the server. * the server calls term_init() with the argc/argv from the client. * bonus: on linux, we now use /proc/self/exe to determine which binary to launch. This means if you run e.g. a foot from your build tree, spawn-terminal will exec _that_ foot, not the system foot. A couple of behavioral changes, and/or side-effects, caused by the above (not exhaustive): * footclient -E: spawn-terminal will not use the _exact_ environment from the original footclient, but will simply pass -E to the new footclient. This means the new instance will inherit the *current* environment of the original instance. * foot htop: spawn-instance will _also_ launch a new foot+htop. Before this patch, spawn-instance would launch a new foot+shell. Closes #1622
Diffstat (limited to 'client-protocol.h')
-rw-r--r--client-protocol.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/client-protocol.h b/client-protocol.h
index efd601d7..391fb6d1 100644
--- a/client-protocol.h
+++ b/client-protocol.h
@@ -9,6 +9,27 @@ struct client_string {
/* char str[static len]; */
};
+/*
+ * Data + options sent from client to server
+ *
+ * - hold: don't exit (the terminal instance) after the slave has terminated
+ * - no-wait: terminate the footclient instance immediately
+ * - xdga-token: for activation
+ * - exe: the filename/path to use when spawning a new footclient instance (used by spawn-terminal)
+ * - cwd: current working directory of the footclient process
+ * - overrides: -o style options
+ * - foot-argc/argv: the raw footclient command line, no processing
+ * - slave-argc/argv: argc+argv passed to the slave
+ * - envp: footclient's environment, copied to the server
+ *
+ * Note that almost everything can be derived from foot argc/argv. In
+ * the future, we _could_ strip the protocol, and do most of the
+ * command line parsing inside the server. For a very long time, foot
+ * argc/argv was *not* part of the protocol, but was added to allow
+ * spawn-terminal to spawn a new footclient instance with the exact
+ * same command line options.
+ */
+
struct client_data {
bool hold:1;
bool no_wait:1;
@@ -16,19 +37,23 @@ struct client_data {
uint8_t reserved:5;
uint8_t token_len;
+ uint16_t exe_len;
uint16_t cwd_len;
uint16_t override_count;
- uint16_t argc;
+ uint16_t foot_argc;
+ uint16_t slave_argc;
uint16_t env_count;
+ /* char exe[static exe_len]; */
/* char cwd[static cwd_len]; */
/* char token[static token_len]; */
/* struct client_string overrides[static override_count]; */
- /* struct client_string argv[static argc]; */
+ /* struct client_string foot_argv[static foot_argc]; */
+ /* struct client_string slave_argv[static slave_argc]; */
/* struct client_string envp[static env_count]; */
} __attribute__((packed));
-_Static_assert(sizeof(struct client_data) == 10, "protocol struct size error");
+_Static_assert(sizeof(struct client_data) == 14, "protocol struct size error");
enum client_ipc_code {
FOOT_IPC_SIGUSR,