some autostart
This commit is contained in:
parent
6655cab11f
commit
f358ed29b0
10
config.h
10
config.h
|
@ -13,6 +13,12 @@ static const float focuscolor[] = { 1, 1, 1, 1 };
|
||||||
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
/* To conform the xdg-protocol, set the alpha to zero to restore the old behavior */
|
||||||
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
static const float fullscreen_bg[] = {0.1, 0.1, 0.1, 1.0};
|
||||||
|
|
||||||
|
/* Autostart */
|
||||||
|
static const char *const autostart[] = {
|
||||||
|
"/bin/sh", "-c", "$HOME/.config/hypr/autostart.sh", NULL,
|
||||||
|
NULL,
|
||||||
|
};
|
||||||
|
|
||||||
/* tagging
|
/* tagging
|
||||||
* expand the array to add more tags
|
* expand the array to add more tags
|
||||||
*/
|
*/
|
||||||
|
@ -136,8 +142,8 @@ static const Key keys[] = {
|
||||||
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
{ MODKEY, XKB_KEY_k, focusstack, {.i = -1} },
|
||||||
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
{ MODKEY, XKB_KEY_i, incnmaster, {.i = +1} },
|
||||||
{ MODKEY, XKB_KEY_n, incnmaster, {.i = -1} },
|
{ MODKEY, XKB_KEY_n, incnmaster, {.i = -1} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_h, setmfact, {.f = -0.05} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_H, setmfact, {.f = -0.05} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_l, setmfact, {.f = +0.05} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_L, setmfact, {.f = +0.05} },
|
||||||
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
{ MODKEY, XKB_KEY_Return, zoom, {0} },
|
||||||
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
{ MODKEY, XKB_KEY_Tab, view, {0} },
|
||||||
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, killclient, {0} },
|
{ MODKEY|WLR_MODIFIER_SHIFT, XKB_KEY_Q, killclient, {0} },
|
||||||
|
|
76
dwl.c
76
dwl.c
|
@ -234,6 +234,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);
|
||||||
|
@ -323,6 +324,8 @@ static void setmon(Client *c, Monitor *m, unsigned int newtags);
|
||||||
static void setpsel(struct wl_listener *listener, void *data);
|
static void setpsel(struct wl_listener *listener, void *data);
|
||||||
static void setsel(struct wl_listener *listener, void *data);
|
static void setsel(struct wl_listener *listener, void *data);
|
||||||
static void setup(void);
|
static void setup(void);
|
||||||
|
static void sigchld(int unused);
|
||||||
|
static void sigchld_sig(int unused);
|
||||||
static void spawn(const Arg *arg);
|
static void spawn(const Arg *arg);
|
||||||
static void startdrag(struct wl_listener *listener, void *data);
|
static void startdrag(struct wl_listener *listener, void *data);
|
||||||
static void tag(const Arg *arg);
|
static void tag(const Arg *arg);
|
||||||
|
@ -428,7 +431,6 @@ static void configurex11(struct wl_listener *listener, void *data);
|
||||||
static void createnotifyx11(struct wl_listener *listener, void *data);
|
static void createnotifyx11(struct wl_listener *listener, void *data);
|
||||||
static Atom getatom(xcb_connection_t *xc, const char *name);
|
static Atom getatom(xcb_connection_t *xc, const char *name);
|
||||||
static void sethints(struct wl_listener *listener, void *data);
|
static void sethints(struct wl_listener *listener, void *data);
|
||||||
static void sigchld(int unused);
|
|
||||||
static void xwaylandready(struct wl_listener *listener, void *data);
|
static void xwaylandready(struct wl_listener *listener, void *data);
|
||||||
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
|
static struct wl_listener new_xwayland_surface = {.notify = createnotifyx11};
|
||||||
static struct wl_listener xwayland_ready = {.notify = xwaylandready};
|
static struct wl_listener xwayland_ready = {.notify = xwaylandready};
|
||||||
|
@ -453,6 +455,9 @@ struct Pertag {
|
||||||
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
const Layout *ltidxs[LENGTH(tags) + 1][2]; /* matrix of tags and layouts indexes */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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)
|
||||||
|
@ -591,6 +596,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)
|
||||||
{
|
{
|
||||||
|
@ -690,10 +716,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);
|
||||||
|
@ -2207,6 +2243,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)
|
||||||
|
@ -2574,6 +2611,41 @@ setup(void)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
sigchld(int unused)
|
||||||
|
{
|
||||||
|
siginfo_t in;
|
||||||
|
/* We should be able to remove this function in favor of a simple
|
||||||
|
* struct sigaction sa = {.sa_handler = SIG_IGN};
|
||||||
|
* sigaction(SIGCHLD, &sa, NULL);
|
||||||
|
* but the Xwayland implementation in wlroots currently prevents us from
|
||||||
|
* setting our own disposition for SIGCHLD.
|
||||||
|
*/
|
||||||
|
/* WNOWAIT leaves the child in a waitable state, in case this is the
|
||||||
|
* XWayland process
|
||||||
|
*/
|
||||||
|
while (!waitid(P_ALL, 0, &in, WEXITED|WNOHANG|WNOWAIT) && in.si_pid
|
||||||
|
#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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
spawn(const Arg *arg)
|
spawn(const Arg *arg)
|
||||||
{
|
{
|
||||||
|
@ -3056,7 +3128,7 @@ sethints(struct wl_listener *listener, void *data)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sigchld(int unused)
|
sigchld_sig(int unused)
|
||||||
{
|
{
|
||||||
siginfo_t in;
|
siginfo_t in;
|
||||||
/* We should be able to remove this function in favor of a simple
|
/* We should be able to remove this function in favor of a simple
|
||||||
|
|
Loading…
Reference in a new issue