mirror of
https://github.com/swaywm/sway.git
synced 2026-04-03 07:15:39 -04:00
Merge 5eb8da6461 into e3c2412565
This commit is contained in:
commit
b666cc1a64
1 changed files with 18 additions and 1 deletions
19
sway/main.c
19
sway/main.c
|
|
@ -208,6 +208,7 @@ static const struct option long_options[] = {
|
||||||
{"verbose", no_argument, NULL, 'V'},
|
{"verbose", no_argument, NULL, 'V'},
|
||||||
{"get-socketpath", no_argument, NULL, 'p'},
|
{"get-socketpath", no_argument, NULL, 'p'},
|
||||||
{"unsupported-gpu", no_argument, NULL, 'u'},
|
{"unsupported-gpu", no_argument, NULL, 'u'},
|
||||||
|
{"ready-fd", required_argument, NULL, 'R'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -221,17 +222,19 @@ static const char usage[] =
|
||||||
" -v, --version Show the version number and quit.\n"
|
" -v, --version Show the version number and quit.\n"
|
||||||
" -V, --verbose Enables more verbose logging.\n"
|
" -V, --verbose Enables more verbose logging.\n"
|
||||||
" --get-socketpath Gets the IPC socket path and prints it, then exits.\n"
|
" --get-socketpath Gets the IPC socket path and prints it, then exits.\n"
|
||||||
|
" -R --ready-fd <fd> Send readiness notification to the given file descriptor.\n"
|
||||||
"\n";
|
"\n";
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
static bool verbose = false, debug = false, validate = false;
|
static bool verbose = false, debug = false, validate = false;
|
||||||
|
|
||||||
char *config_path = NULL;
|
char *config_path = NULL;
|
||||||
|
int ready_fd;
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while (1) {
|
while (1) {
|
||||||
int option_index = 0;
|
int option_index = 0;
|
||||||
c = getopt_long(argc, argv, "hCdD:vVc:", long_options, &option_index);
|
c = getopt_long(argc, argv, "hCdD:vVc:R:", long_options, &option_index);
|
||||||
if (c == -1) {
|
if (c == -1) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -272,6 +275,9 @@ int main(int argc, char **argv) {
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'R': // --ready-fd
|
||||||
|
ready_fd = strtol(optarg, NULL, 10);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "%s", usage);
|
fprintf(stderr, "%s", usage);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
@ -373,6 +379,17 @@ int main(int argc, char **argv) {
|
||||||
swaynag_show(&config->swaynag_config_errors);
|
swaynag_show(&config->swaynag_config_errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ready_fd >= 0) {
|
||||||
|
// s6 wants a newline and ignores any text before that, systemd wants
|
||||||
|
// READY=1, so use the least common denominator
|
||||||
|
const char ready_str[] = "READY=1\n";
|
||||||
|
if (write(ready_fd, ready_str, strlen(ready_str)) != (ssize_t) strlen(ready_str)) {
|
||||||
|
sway_log(SWAY_INFO, "Failed to send readiness notification");
|
||||||
|
}
|
||||||
|
close(ready_fd);
|
||||||
|
ready_fd = -1;
|
||||||
|
}
|
||||||
|
|
||||||
server_run(&server);
|
server_run(&server);
|
||||||
|
|
||||||
shutdown:
|
shutdown:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue