Add restartsig

This commit is contained in:
Jacob 2023-07-06 19:25:17 +02:00
parent 0c66e7b813
commit a0803fae0b
3 changed files with 36 additions and 2 deletions

View file

@ -127,8 +127,8 @@ static const Key keys[] = {
{ MODKEY, XK_n, incnmaster, {.i = -1 } },
{ MODKEY|ControlMask, XK_i, incnstack, {.i = +1 } },
{ MODKEY|ControlMask, XK_u, incnstack, {.i = -1 } },
{ MODKEY|ShiftMask, XK_a, setmfact, {.f = -0.05} },
{ MODKEY|ShiftMask, XK_d, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_h, setmfact, {.f = -0.05} },
{ MODKEY|ShiftMask, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_k, setcfact, {.f = +0.25} },
{ MODKEY|ShiftMask, XK_j, setcfact, {.f = -0.25} },
{ MODKEY|ShiftMask, XK_o, setcfact, {.f = 0.00} },
@ -147,6 +147,7 @@ static const Key keys[] = {
{ MODKEY|Mod1Mask, XK_9, incrovgaps, {.i = +1 } },
{ MODKEY|Mod1Mask|ShiftMask, XK_9, incrovgaps, {.i = -1 } },
{ MODKEY|Mod1Mask|ShiftMask, XK_0, defaultgaps, {0} },
{ MODKEY|ControlMask|ShiftMask, XK_r, quit, {.i = 1 } },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ControlMask, XK_z, showhideclient, {0} },

10
dwm.1
View file

@ -142,6 +142,9 @@ Add/remove all windows with nth tag to/from the view.
.TP
.B Mod1\-Shift\-q
Quit dwm.
.TP
.B Mod1\-Control\-Shift\-q
Restart dwm.
.SS Mouse commands
.TP
.B Mod1\-Button1
@ -155,6 +158,13 @@ Resize focused window while dragging. Tiled windows will be toggled to the float
.SH CUSTOMIZATION
dwm is customized by creating a custom config.h and (re)compiling the source
code. This keeps it fast, secure and simple.
.SH SIGNALS
.TP
.B SIGHUP - 1
Restart the dwm process.
.TP
.B SIGTERM - 15
Cleanly terminate the dwm process.
.SH SEE ALSO
.BR dmenu (1),
.BR st (1)

23
dwm.c
View file

@ -317,6 +317,8 @@ static void setup(void);
static void seturgent(Client *c, int urg);
static void showhide(Client *c);
static void spawn(const Arg *arg);
static void sighup(int unused);
static void sigterm(int unused);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
static void togglebar(const Arg *arg);
@ -391,6 +393,7 @@ static void (*handler[LASTEvent]) (XEvent *) = {
};
static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast];
static int running = 1;
static int restart = 0;
static Cur *cursor[CurLast];
static Display *dpy;
static Drw *drw;
@ -1855,6 +1858,8 @@ quit(const Arg *arg)
{
size_t i;
if(arg->i) restart = 1;
/* kill child processes */
for (i = 0; i < autostart_len; i++) {
if (0 < autostart_pids[i]) {
@ -2253,6 +2258,9 @@ setup(void)
}
signal(SIGHUP, sighup);
signal(SIGTERM, sigterm);
/* init screen */
screen = DefaultScreen(dpy);
sw = DisplayWidth(dpy, screen);
@ -2363,6 +2371,20 @@ showhide(Client *c)
}
}
void
sighup(int unused)
{
Arg a = {.i = 1};
quit(&a);
}
void
sigterm(int unused)
{
Arg a = {.i = 0};
quit(&a);
}
void
spawn(const Arg *arg)
{
@ -3246,6 +3268,7 @@ main(int argc, char *argv[])
#endif /* __OpenBSD__ */
scan();
run();
if(restart) execvp(argv[0], argv);
cleanup();
XCloseDisplay(dpy);
return EXIT_SUCCESS;