mirror of
https://codeberg.org/dwl/dwl.git
synced 2025-01-30 04:37:28 -08:00
apply autostart patch from dwm
https://dwm.suckless.org/patches/cool_autostart/
This commit is contained in:
parent
09d177c13a
commit
bfa2cbb848
2 changed files with 60 additions and 5 deletions
|
@ -108,6 +108,12 @@ LIBINPUT_CONFIG_TAP_MAP_LMR -- 1/2/3 finger tap maps to left/middle/right
|
|||
*/
|
||||
static const enum libinput_config_tap_button_map button_map = LIBINPUT_CONFIG_TAP_MAP_LRM;
|
||||
|
||||
/* Autostart */
|
||||
static const char *const autostart[] = {
|
||||
"sh", "-c", "swaybg --image /xap/local/background", NULL,
|
||||
NULL /* terminate */
|
||||
};
|
||||
|
||||
/* If you want to use the windows key for MODKEY, use WLR_MODIFIER_LOGO */
|
||||
#define MODKEY WLR_MODIFIER_ALT
|
||||
|
||||
|
|
59
dwl.c
59
dwl.c
|
@ -254,6 +254,7 @@ static void arrange(Monitor *m);
|
|||
static void arrangelayer(Monitor *m, struct wl_list *list,
|
||||
struct wlr_box *usable_area, int exclusive);
|
||||
static void arrangelayers(Monitor *m);
|
||||
static void autostartexec(void);
|
||||
static void axisnotify(struct wl_listener *listener, void *data);
|
||||
static void buttonpress(struct wl_listener *listener, void *data);
|
||||
static void checkconstraintregion(void);
|
||||
|
@ -435,6 +436,9 @@ static xcb_atom_t netatom[NetLast];
|
|||
/* attempt to encapsulate suck into one file */
|
||||
#include "client.h"
|
||||
|
||||
static pid_t *autostart_pids;
|
||||
static size_t autostart_len;
|
||||
|
||||
/* function implementations */
|
||||
void
|
||||
applybounds(Client *c, struct wlr_box *bbox)
|
||||
|
@ -453,6 +457,27 @@ applybounds(Client *c, struct wlr_box *bbox)
|
|||
c->geom.y = bbox->y;
|
||||
}
|
||||
|
||||
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 failed:", *p);
|
||||
}
|
||||
/* skip arguments */
|
||||
while (*++p);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
applyrules(Client *c)
|
||||
{
|
||||
|
@ -704,11 +729,21 @@ checkidleinhibitor(struct wlr_surface *exclude)
|
|||
void
|
||||
cleanup(void)
|
||||
{
|
||||
size_t i;
|
||||
#ifdef XWAYLAND
|
||||
wlr_xwayland_destroy(xwayland);
|
||||
xwayland = NULL;
|
||||
#endif
|
||||
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) {
|
||||
kill(child_pid, SIGTERM);
|
||||
waitpid(child_pid, NULL, 0);
|
||||
|
@ -1569,18 +1604,31 @@ void
|
|||
handlesig(int signo)
|
||||
{
|
||||
if (signo == SIGCHLD) {
|
||||
#ifdef XWAYLAND
|
||||
siginfo_t in;
|
||||
/* wlroots expects to reap the XWayland process itself, so we
|
||||
* use WNOWAIT to keep the child waitable until we know it's not
|
||||
* XWayland.
|
||||
*/
|
||||
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
|
||||
&& (!xwayland || in.si_pid != xwayland->server->pid))
|
||||
waitpid(in.si_pid, NULL, 0);
|
||||
#else
|
||||
while (waitpid(-1, NULL, WNOHANG) > 0);
|
||||
#ifdef XWAYLAND
|
||||
&& (!xwayland || in.si_pid != xwayland->server->pid)
|
||||
#endif
|
||||
) {
|
||||
pid_t *p, *lim;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (signo == SIGINT || signo == SIGTERM) {
|
||||
quit(NULL);
|
||||
}
|
||||
|
@ -2276,6 +2324,7 @@ run(char *startup_cmd)
|
|||
die("startup: backend_start");
|
||||
|
||||
/* Now that the socket exists and the backend is started, run the startup command */
|
||||
autostartexec();
|
||||
if (startup_cmd) {
|
||||
int piperw[2];
|
||||
if (pipe(piperw) < 0)
|
||||
|
|
Loading…
Reference in a new issue