From 19157d35649f96aa04d26036a76eaed65de60944 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 12 Nov 2024 22:54:58 +0100 Subject: [PATCH] Make application arguments optional If no application is specified, run without starting a child process. Leave it up to the user to start applications externally and stop cage with a signal. --- cage.1.scd | 2 +- cage.c | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/cage.1.scd b/cage.1.scd index 58c4ed1..ed1f518 100644 --- a/cage.1.scd +++ b/cage.1.scd @@ -6,7 +6,7 @@ cage - a Wayland kiosk compositor # SYNOPSIS -*cage* [options...] [--] _application_ [application argument ...] +*cage* [options...] [--] [_application_...] # DESCRIPTION diff --git a/cage.c b/cage.c index 61c9386..631b95a 100644 --- a/cage.c +++ b/cage.c @@ -224,7 +224,7 @@ static void usage(FILE *file, const char *cage) { fprintf(file, - "Usage: %s [OPTIONS] [--] APPLICATION\n" + "Usage: %s [OPTIONS] [--] [APPLICATION...]\n" "\n" " -d\t Don't draw client side decorations, when possible\n" " -D\t Enable debug logging\n" @@ -272,11 +272,6 @@ parse_args(struct cg_server *server, int argc, char *argv[]) } } - if (optind >= argc) { - usage(stderr, argv[0]); - return false; - } - return true; } @@ -592,7 +587,7 @@ main(int argc, char *argv[]) } #endif - if (!spawn_primary_client(&server, argv + optind, &pid, &sigchld_source)) { + if (optind < argc && !spawn_primary_client(&server, argv + optind, &pid, &sigchld_source)) { ret = 1; goto end; } @@ -607,7 +602,8 @@ main(int argc, char *argv[]) wl_display_destroy_clients(server.wl_display); end: - app_ret = cleanup_primary_client(pid); + if (pid != 0) + app_ret = cleanup_primary_client(pid); if (!ret && server.return_app_code) ret = app_ret;