mirror of
https://github.com/swaywm/sway.git
synced 2025-10-08 13:16:05 +00:00
Merge 5eb8da6461
into 90d3270970
This commit is contained in:
commit
626b927a7e
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'},
|
||||
{"get-socketpath", no_argument, NULL, 'p'},
|
||||
{"unsupported-gpu", no_argument, NULL, 'u'},
|
||||
{"ready-fd", required_argument, NULL, 'R'},
|
||||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
|
@ -221,17 +222,19 @@ static const char usage[] =
|
|||
" -v, --version Show the version number and quit.\n"
|
||||
" -V, --verbose Enables more verbose logging.\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";
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
static bool verbose = false, debug = false, validate = false;
|
||||
|
||||
char *config_path = NULL;
|
||||
int ready_fd;
|
||||
|
||||
int c;
|
||||
while (1) {
|
||||
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) {
|
||||
break;
|
||||
}
|
||||
|
@ -272,6 +275,9 @@ int main(int argc, char **argv) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
break;
|
||||
case 'R': // --ready-fd
|
||||
ready_fd = strtol(optarg, NULL, 10);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "%s", usage);
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -373,6 +379,17 @@ int main(int argc, char **argv) {
|
|||
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);
|
||||
|
||||
shutdown:
|
||||
|
|
Loading…
Add table
Reference in a new issue