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.
This commit is contained in:
Simon Ser 2024-11-12 22:54:58 +01:00
parent 852839e59f
commit 19157d3564
2 changed files with 5 additions and 9 deletions

View file

@ -6,7 +6,7 @@ cage - a Wayland kiosk compositor
# SYNOPSIS # SYNOPSIS
*cage* [options...] [--] _application_ [application argument ...] *cage* [options...] [--] [_application_...]
# DESCRIPTION # DESCRIPTION

12
cage.c
View file

@ -224,7 +224,7 @@ static void
usage(FILE *file, const char *cage) usage(FILE *file, const char *cage)
{ {
fprintf(file, fprintf(file,
"Usage: %s [OPTIONS] [--] APPLICATION\n" "Usage: %s [OPTIONS] [--] [APPLICATION...]\n"
"\n" "\n"
" -d\t Don't draw client side decorations, when possible\n" " -d\t Don't draw client side decorations, when possible\n"
" -D\t Enable debug logging\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; return true;
} }
@ -592,7 +587,7 @@ main(int argc, char *argv[])
} }
#endif #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; ret = 1;
goto end; goto end;
} }
@ -607,7 +602,8 @@ main(int argc, char *argv[])
wl_display_destroy_clients(server.wl_display); wl_display_destroy_clients(server.wl_display);
end: end:
app_ret = cleanup_primary_client(pid); if (pid != 0)
app_ret = cleanup_primary_client(pid);
if (!ret && server.return_app_code) if (!ret && server.return_app_code)
ret = app_ret; ret = app_ret;