mirror of
https://github.com/labwc/labwc.git
synced 2025-11-04 13:30:07 -05:00
Add -S|--session <command> option
...to start <command> on startup and to terminate the compositor when <command> exits. This is useful for session management as it allows the session client (for example `lxqt-session`) to terminate labwc - be exiting itself. Under X, xinit starts the server and keeps it alive for as long as lxqt-session runs. Thus either the session client starts the Window Manager, or the Window Manager can be launched independently first. On Wayland, the Compositor is both Display Server and Window Manager, so the described session management mechanisms do not work because the Compositor needs to be running before the session can function. As some session clients support both X11 and Wayland, this command line option avoids re-writes and fragmentation. Co-authored-by: @Consolatis
This commit is contained in:
parent
55138dbe0e
commit
c841a25acf
6 changed files with 95 additions and 5 deletions
|
|
@ -25,11 +25,22 @@ reset_signals_and_limits(void)
|
|||
signal(SIGPIPE, SIG_DFL);
|
||||
}
|
||||
|
||||
static void
|
||||
static bool
|
||||
set_cloexec(int fd)
|
||||
{
|
||||
int flags = fcntl(fd, F_GETFD);
|
||||
fcntl(fd, F_SETFD, flags | FD_CLOEXEC);
|
||||
if (flags == -1) {
|
||||
wlr_log_errno(WLR_ERROR,
|
||||
"Unable to set the CLOEXEC flag: fnctl failed");
|
||||
return false;
|
||||
}
|
||||
flags = flags | FD_CLOEXEC;
|
||||
if (fcntl(fd, F_SETFD, flags) == -1) {
|
||||
wlr_log_errno(WLR_ERROR,
|
||||
"Unable to set the CLOEXEC flag: fnctl failed");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -79,6 +90,41 @@ out:
|
|||
g_strfreev(argv);
|
||||
}
|
||||
|
||||
pid_t
|
||||
spawn_primary_client(const char *command)
|
||||
{
|
||||
assert(command);
|
||||
|
||||
GError *err = NULL;
|
||||
gchar **argv = NULL;
|
||||
|
||||
/* Use glib's shell-parse to mimic Openbox's behaviour */
|
||||
g_shell_parse_argv((gchar *)command, NULL, &argv, &err);
|
||||
if (err) {
|
||||
g_message("%s", err->message);
|
||||
g_error_free(err);
|
||||
return -1;
|
||||
}
|
||||
|
||||
pid_t child = fork();
|
||||
switch (child) {
|
||||
case -1:
|
||||
wlr_log_errno(WLR_ERROR, "Failed to fork");
|
||||
g_strfreev(argv);
|
||||
return -1;
|
||||
case 0:
|
||||
/* child */
|
||||
close(STDIN_FILENO);
|
||||
reset_signals_and_limits();
|
||||
execvp(argv[0], argv);
|
||||
wlr_log_errno(WLR_ERROR, "Failed to execute primary client %s", command);
|
||||
_exit(1);
|
||||
default:
|
||||
g_strfreev(argv);
|
||||
return child;
|
||||
}
|
||||
}
|
||||
|
||||
pid_t
|
||||
spawn_piped(const char *command, int *pipe_fd)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue