mirror of
https://github.com/swaywm/sway.git
synced 2026-03-11 05:34:18 -04:00
Spawn swaynag as a wayland client
This spawns swaynag as a wayland client similar to how swaybar and swaybg are already done
This commit is contained in:
parent
8c69da11bb
commit
6961bf2e4c
8 changed files with 147 additions and 71 deletions
|
|
@ -45,17 +45,24 @@ static void swaynag_button_execute(struct swaynag *swaynag,
|
|||
swaynag->details.visible = !swaynag->details.visible;
|
||||
render_frame(swaynag);
|
||||
} else {
|
||||
if (fork() == 0) {
|
||||
pid_t pid = fork();
|
||||
if (pid < 0) {
|
||||
sway_log_errno(SWAY_DEBUG, "Failed to fork");
|
||||
return;
|
||||
} else if (pid == 0) {
|
||||
// Child process. Will be used to prevent zombie processes
|
||||
setsid();
|
||||
if (fork() == 0) {
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
sway_log_errno(SWAY_DEBUG, "Failed to fork");
|
||||
return;
|
||||
} else if (pid == 0) {
|
||||
// Child of the child. Will be reparented to the init process
|
||||
char *terminal = getenv("TERMINAL");
|
||||
if (button->terminal && terminal && strlen(terminal)) {
|
||||
sway_log(SWAY_DEBUG, "Found $TERMINAL: %s", terminal);
|
||||
if (!terminal_execute(terminal, button->action)) {
|
||||
swaynag_destroy(swaynag);
|
||||
exit(EXIT_FAILURE);
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
} else {
|
||||
if (button->terminal) {
|
||||
|
|
@ -63,12 +70,16 @@ static void swaynag_button_execute(struct swaynag *swaynag,
|
|||
"$TERMINAL not found. Running directly");
|
||||
}
|
||||
execl("/bin/sh", "/bin/sh", "-c", button->action, NULL);
|
||||
sway_log_errno(SWAY_DEBUG, "execl failed");
|
||||
_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
exit(EXIT_SUCCESS);
|
||||
_exit(EXIT_SUCCESS);
|
||||
}
|
||||
if (waitpid(pid, NULL, 0) < 0) {
|
||||
sway_log_errno(SWAY_DEBUG, "waitpid failed");
|
||||
}
|
||||
}
|
||||
wait(0);
|
||||
}
|
||||
|
||||
static void layer_surface_configure(void *data,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue