From 3943cad7edcafafab0b1a5c1aff25ff3518012f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 26 May 2020 20:11:38 +0200 Subject: [PATCH 1/4] client/server: implement '--hold' in footclient --- client.c | 13 +++++++++++++ server.c | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/client.c b/client.c index 1458c7cd..0d0feb49 100644 --- a/client.c +++ b/client.c @@ -39,6 +39,7 @@ print_usage(const char *prog_name) " --fullscreen start in fullscreen mode\n" " --login-shell start shell as a login shell\n" " -s,--server-socket=PATH path to the server UNIX domain socket (default=$XDG_RUNTIME_DIR/foot-$XDG_SESSION_ID.sock)\n" + " --hold remain open after child process exits\n" " -l,--log-colorize=[never|always|auto] enable/disable colorization of log output on stderr\n" " -v,--version show the version number and quit\n"); } @@ -58,6 +59,7 @@ main(int argc, char *const *argv) {"fullscreen", no_argument, NULL, 'F'}, {"login-shell", no_argument, NULL, 'L'}, {"server-socket", required_argument, NULL, 's'}, + {"hold", no_argument, NULL, 'H'}, {"log-colorize", optional_argument, NULL, 'l'}, {"version", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, @@ -72,6 +74,7 @@ main(int argc, char *const *argv) bool login_shell = false; bool maximized = false; bool fullscreen = false; + bool hold = false; while (true) { int c = getopt_long(argc, argv, "+:t:a:s:l::hv", longopts, NULL); @@ -109,6 +112,10 @@ main(int argc, char *const *argv) server_socket_path = optarg; break; + case 'H': + hold = true; + break; + case 'l': if (optarg == NULL || strcmp(optarg, "auto") == 0) log_colorize = LOG_COLORIZE_AUTO; @@ -212,6 +219,7 @@ main(int argc, char *const *argv) total_len += sizeof(app_id_len) + app_id_len; total_len += sizeof(uint8_t); /* maximized */ total_len += sizeof(uint8_t); /* fullscreen */ + total_len += sizeof(uint8_t); /* hold */ total_len += sizeof(uint8_t); /* login_shell */ total_len += sizeof(argc); @@ -266,6 +274,11 @@ main(int argc, char *const *argv) goto err; } + if (send(fd, &(uint8_t){hold}, sizeof(uint8_t), 0) != sizeof(uint8_t)) { + LOG_ERRNO("failed to send hold"); + goto err; + } + if (send(fd, &(uint8_t){login_shell}, sizeof(uint8_t), 0) != sizeof(uint8_t)) { LOG_ERRNO("failed to send login-shell"); goto err; diff --git a/server.c b/server.c index ab627877..c2778ad7 100644 --- a/server.c +++ b/server.c @@ -267,6 +267,9 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) CHECK_BUF(sizeof(uint8_t)); const uint8_t fullscreen = *(const uint8_t *)p; p += sizeof(fullscreen); + CHECK_BUF(sizeof(uint8_t)); + const uint8_t hold = *(const uint8_t *)p; p += sizeof(hold); + CHECK_BUF(sizeof(uint8_t)); const uint8_t login_shell = *(const uint8_t *)p; p += sizeof(login_shell); @@ -304,6 +307,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) ? strdup(title) : strdup(server->conf->title); client->conf.app_id = strlen(app_id) > 0 ? strdup(app_id) : strdup(server->conf->app_id); + client->conf.hold_at_exit = hold; client->conf.login_shell = login_shell; if (maximized) From fbfbcc453c1d5b56101145f42c83ddacb44bea7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 26 May 2020 20:12:35 +0200 Subject: [PATCH 2/4] completions: zsh: footclient: add --hold --- completions/zsh/_footclient | 1 + 1 file changed, 1 insertion(+) diff --git a/completions/zsh/_footclient b/completions/zsh/_footclient index e406beec..6eb66066 100644 --- a/completions/zsh/_footclient +++ b/completions/zsh/_footclient @@ -9,6 +9,7 @@ _arguments \ '--fullscreen[start in fullscreen mode]' \ '--login-shell[start shell as a login shell]' \ '(-s --server-socket)'{-s,--server-socket}'[override the default path to the foot server socket (XDG_RUNTIME_DIR/foot.sock)]:server:_files' \ + '--hold[remain open after child process exits]' \ '(-l --log-colorize)'{-l,--log-colorize}'[enable or disable colorization of log output on stderr]:logcolor:(never always auto)' \ '(-v --version)'{-v,--version}'[show the version number and quit]' \ '(-h --help)'{-h,--help}'[show help message and quit]' \ From aa5e84727b786e8af7cc4e74a4fda78b96bc3555 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 26 May 2020 20:12:44 +0200 Subject: [PATCH 3/4] doc: footclient: add --hold --- doc/footclient.1.scd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/footclient.1.scd b/doc/footclient.1.scd index 9a43b26b..4f65bf9d 100644 --- a/doc/footclient.1.scd +++ b/doc/footclient.1.scd @@ -36,6 +36,9 @@ arguments, to execute (instead of the default shell). *-s*,*--server-socket*=_PATH_ Connect to _PATH_ instead of _XDG\_RUNTIME\_DIR/foot.sock_. +*--hold* + Remain open after child process exits. + *-l*,*--log-colorize*=[{*never*,*always*,*auto*}] Enables or disables colorization of log output on stderr. From e02121ae244588a0bd8830ed9c2288d51adb106f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Tue, 26 May 2020 20:12:53 +0200 Subject: [PATCH 4/4] changelog: mention addition of '--hold' to footclient --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6707efa1..094bcf6e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ * `Sync` to terminfo. This is a tmux extension that indicates _"Synchronized Updates"_ are supported. +* `--hold` command line option to `footclient`. ### Changed