birdwm

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 346cb8e12cdde20f57cd71c9e752b5bc6ce38409
parent 77311a7220db641fdc1ef921ab451179a62ec50a
Author: grouse <bdmfegys@duck.com>
Date:   Fri,  1 Dec 2023 23:50:21 -0500

successfully built after restartsig patch

Diffstat:
Mdwm.1 | 10++++++++++
Mdwm.c | 22++++++++++++++++++++++
2 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/dwm.1 b/dwm.1 @@ -150,6 +150,9 @@ Add/remove all windows with nth tag to/from the view. .TP .B Mod1\-Shift\-q Quit birdwm. +.TP +.B Mod1\-Control\-Shift\-q +Restart birdwm. .SS Mouse commands .TP .B Mod1\-Button1 @@ -178,6 +181,13 @@ This file is started before any autostart.sh; birdwm waits for its termination. .SH CUSTOMIZATION birdwm 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) diff --git a/dwm.c b/dwm.c @@ -260,6 +260,8 @@ static void setmfact(const Arg *arg); static void setup(void); static void seturgent(Client *c, int urg); static void showhide(Client *c); +static void sighup(int unused); +static void sigterm(int unused); static void spawn(const Arg *arg); static Monitor *systraytomon(Monitor *m); static void tag(const Arg *arg); @@ -330,6 +332,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [UnmapNotify] = unmapnotify }; static Atom wmatom[WMLast], netatom[NetLast], xatom[XLast]; +static int restart = 0; static int running = 1; static Cur *cursor[CurLast]; static Clr **scheme; @@ -1541,6 +1544,7 @@ propertynotify(XEvent *e) void quit(const Arg *arg) { + if(arg->i) restart = 1; running = 0; } @@ -1971,6 +1975,9 @@ setup(void) /* clean up any zombies (inherited from .xinitrc etc) immediately */ while (waitpid(-1, NULL, WNOHANG) > 0); + signal(SIGHUP, sighup); + signal(SIGTERM, sigterm); + /* init screen */ screen = DefaultScreen(dpy); sw = DisplayWidth(dpy, screen); @@ -2081,6 +2088,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) { struct sigaction sa; @@ -2874,6 +2895,7 @@ main(int argc, char *argv[]) scan(); runautostart(); run(); + if(restart) execvp(argv[0], argv); cleanup(); XCloseDisplay(dpy); return EXIT_SUCCESS;