Skip to content

Commit 19157d3

Browse files
committed
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.
1 parent 852839e commit 19157d3

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

cage.1.scd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ cage - a Wayland kiosk compositor
66

77
# SYNOPSIS
88

9-
*cage* [options...] [--] _application_ [application argument ...]
9+
*cage* [options...] [--] [_application_...]
1010

1111
# DESCRIPTION
1212

cage.c

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ static void
224224
usage(FILE *file, const char *cage)
225225
{
226226
fprintf(file,
227-
"Usage: %s [OPTIONS] [--] APPLICATION\n"
227+
"Usage: %s [OPTIONS] [--] [APPLICATION...]\n"
228228
"\n"
229229
" -d\t Don't draw client side decorations, when possible\n"
230230
" -D\t Enable debug logging\n"
@@ -272,11 +272,6 @@ parse_args(struct cg_server *server, int argc, char *argv[])
272272
}
273273
}
274274

275-
if (optind >= argc) {
276-
usage(stderr, argv[0]);
277-
return false;
278-
}
279-
280275
return true;
281276
}
282277

@@ -592,7 +587,7 @@ main(int argc, char *argv[])
592587
}
593588
#endif
594589

595-
if (!spawn_primary_client(&server, argv + optind, &pid, &sigchld_source)) {
590+
if (optind < argc && !spawn_primary_client(&server, argv + optind, &pid, &sigchld_source)) {
596591
ret = 1;
597592
goto end;
598593
}
@@ -607,7 +602,8 @@ main(int argc, char *argv[])
607602
wl_display_destroy_clients(server.wl_display);
608603

609604
end:
610-
app_ret = cleanup_primary_client(pid);
605+
if (pid != 0)
606+
app_ret = cleanup_primary_client(pid);
611607
if (!ret && server.return_app_code)
612608
ret = app_ret;
613609

0 commit comments

Comments
 (0)