mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-12-17 10:23:19 +00:00
apply autostart patch from dwm
https://dwm.suckless.org/patches/cool_autostart/
This commit is contained in:
parent
159670c3a2
commit
17127dec10
@ -10,6 +10,12 @@ static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
|||||||
/* tagging - tagcount must be no greater than 31 */
|
/* tagging - tagcount must be no greater than 31 */
|
||||||
static const int tagcount = 9;
|
static const int tagcount = 9;
|
||||||
|
|
||||||
|
/* Autostart */
|
||||||
|
static const char *const autostart[] = {
|
||||||
|
"wbg", "/path/to/your/image", NULL,
|
||||||
|
NULL /* terminate */
|
||||||
|
};
|
||||||
|
|
||||||
static const Rule rules[] = {
|
static const Rule rules[] = {
|
||||||
/* app_id title tags mask isfloating monitor */
|
/* app_id title tags mask isfloating monitor */
|
||||||
/* examples:
|
/* examples:
|
||||||
|
|||||||
62
dwl.c
62
dwl.c
@ -231,6 +231,7 @@ static void arrange(Monitor *m);
|
|||||||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||||
struct wlr_box *usable_area, int exclusive);
|
struct wlr_box *usable_area, int exclusive);
|
||||||
static void arrangelayers(Monitor *m);
|
static void arrangelayers(Monitor *m);
|
||||||
|
static void autostartexec(void);
|
||||||
static void axisnotify(struct wl_listener *listener, void *data);
|
static void axisnotify(struct wl_listener *listener, void *data);
|
||||||
static void buttonpress(struct wl_listener *listener, void *data);
|
static void buttonpress(struct wl_listener *listener, void *data);
|
||||||
static void chvt(const Arg *arg);
|
static void chvt(const Arg *arg);
|
||||||
@ -417,6 +418,9 @@ static Atom netatom[NetLast];
|
|||||||
/* attempt to encapsulate suck into one file */
|
/* attempt to encapsulate suck into one file */
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
|
|
||||||
|
static pid_t *autostart_pids;
|
||||||
|
static size_t autostart_len;
|
||||||
|
|
||||||
/* function implementations */
|
/* function implementations */
|
||||||
void
|
void
|
||||||
applybounds(Client *c, struct wlr_box *bbox)
|
applybounds(Client *c, struct wlr_box *bbox)
|
||||||
@ -557,6 +561,27 @@ arrangelayers(Monitor *m)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
autostartexec(void) {
|
||||||
|
const char *const *p;
|
||||||
|
size_t i = 0;
|
||||||
|
|
||||||
|
/* count entries */
|
||||||
|
for (p = autostart; *p; autostart_len++, p++)
|
||||||
|
while (*++p);
|
||||||
|
|
||||||
|
autostart_pids = calloc(autostart_len, sizeof(pid_t));
|
||||||
|
for (p = autostart; *p; i++, p++) {
|
||||||
|
if ((autostart_pids[i] = fork()) == 0) {
|
||||||
|
setsid();
|
||||||
|
execvp(*p, (char *const *)p);
|
||||||
|
die("dwl: execvp %s:", *p);
|
||||||
|
}
|
||||||
|
/* skip arguments */
|
||||||
|
while (*++p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
axisnotify(struct wl_listener *listener, void *data)
|
axisnotify(struct wl_listener *listener, void *data)
|
||||||
{
|
{
|
||||||
@ -657,10 +682,20 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
|||||||
void
|
void
|
||||||
cleanup(void)
|
cleanup(void)
|
||||||
{
|
{
|
||||||
|
size_t i;
|
||||||
|
|
||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
wlr_xwayland_destroy(xwayland);
|
wlr_xwayland_destroy(xwayland);
|
||||||
#endif
|
#endif
|
||||||
wl_display_destroy_clients(dpy);
|
wl_display_destroy_clients(dpy);
|
||||||
|
|
||||||
|
/* kill child processes */
|
||||||
|
for (i = 0; i < autostart_len; i++) {
|
||||||
|
if (0 < autostart_pids[i]) {
|
||||||
|
kill(autostart_pids[i], SIGTERM);
|
||||||
|
waitpid(autostart_pids[i], NULL, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (child_pid > 0) {
|
if (child_pid > 0) {
|
||||||
kill(child_pid, SIGTERM);
|
kill(child_pid, SIGTERM);
|
||||||
waitpid(child_pid, NULL, 0);
|
waitpid(child_pid, NULL, 0);
|
||||||
@ -1962,6 +1997,7 @@ run(char *startup_cmd)
|
|||||||
die("startup: backend_start");
|
die("startup: backend_start");
|
||||||
|
|
||||||
/* Now that the socket exists and the backend is started, run the startup command */
|
/* Now that the socket exists and the backend is started, run the startup command */
|
||||||
|
autostartexec();
|
||||||
if (startup_cmd) {
|
if (startup_cmd) {
|
||||||
int piperw[2];
|
int piperw[2];
|
||||||
if (pipe(piperw) < 0)
|
if (pipe(piperw) < 0)
|
||||||
@ -2134,15 +2170,7 @@ void
|
|||||||
setup(void)
|
setup(void)
|
||||||
{
|
{
|
||||||
struct sigaction sa_term = {.sa_flags = SA_RESTART, .sa_handler = quitsignal};
|
struct sigaction sa_term = {.sa_flags = SA_RESTART, .sa_handler = quitsignal};
|
||||||
struct sigaction sa_sigchld = {
|
struct sigaction sa_sigchld = { .sa_flags = SA_RESTART, .sa_handler = sigchld};
|
||||||
#ifdef XWAYLAND
|
|
||||||
.sa_flags = SA_RESTART,
|
|
||||||
.sa_handler = sigchld,
|
|
||||||
#else
|
|
||||||
.sa_flags = SA_NOCLDSTOP | SA_NOCLDWAIT | SA_RESTART,
|
|
||||||
.sa_handler = SIG_IGN,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
sigemptyset(&sa_term.sa_mask);
|
sigemptyset(&sa_term.sa_mask);
|
||||||
sigemptyset(&sa_sigchld.sa_mask);
|
sigemptyset(&sa_sigchld.sa_mask);
|
||||||
/* The Wayland display is managed by libwayland. It handles accepting
|
/* The Wayland display is managed by libwayland. It handles accepting
|
||||||
@ -2357,8 +2385,22 @@ sigchld(int unused)
|
|||||||
#ifdef XWAYLAND
|
#ifdef XWAYLAND
|
||||||
&& (!xwayland || in.si_pid != xwayland->server->pid)
|
&& (!xwayland || in.si_pid != xwayland->server->pid)
|
||||||
#endif
|
#endif
|
||||||
)
|
) {
|
||||||
|
pid_t *p, *lim;
|
||||||
waitpid(in.si_pid, NULL, 0);
|
waitpid(in.si_pid, NULL, 0);
|
||||||
|
if (in.si_pid == child_pid)
|
||||||
|
child_pid = -1;
|
||||||
|
if (!(p = autostart_pids))
|
||||||
|
continue;
|
||||||
|
lim = &p[autostart_len];
|
||||||
|
|
||||||
|
for (; p < lim; p++) {
|
||||||
|
if (*p == in.si_pid) {
|
||||||
|
*p = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user