diff options
| author | Warrick Lo <warrick.s.z.lo@gmail.com> | 2021-11-24 03:36:17 -0800 |
|---|---|---|
| committer | Warrick Lo <warrick.s.z.lo@gmail.com> | 2021-11-24 03:36:17 -0800 |
| commit | 0597ab7eabfe7b6a1a17a75b8ec2922ab4eff816 (patch) | |
| tree | 9df2d4e4223bc7d9a78f3b445f6657b6eddda676 | |
| parent | Always center floating windows (diff) | |
Add restarting functionality
| -rw-r--r-- | config.def.h | 3 | ||||
| -rw-r--r-- | dwm.c | 22 |
2 files changed, 24 insertions, 1 deletions
diff --git a/config.def.h b/config.def.h index d40c2c6..0d20449 100644 --- a/config.def.h +++ b/config.def.h @@ -37,7 +37,7 @@ static const Rule rules[] = { /* class instance title tags mask isfloating isterminal noswallow monitor */ { "Gimp", NULL, NULL, 0, 1, 0, 0, -1 }, { "Firefox", NULL, NULL, 1 << 8, 0, 0, -1, -1 }, - { "Alacritty", NULL, NULL, 0, 0, 1, 0, -1 }, + { "St", NULL, NULL, 0, 0, 1, 0, -1 }, { NULL, NULL, "Event Tester", 0, 1, 0, 1, -1 }, /* xev */ }; @@ -112,6 +112,7 @@ static Key keys[] = { TAGKEYS( XK_8, 7) TAGKEYS( XK_9, 8) { MODKEY|ShiftMask, XK_q, quit, {0} }, + { MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} }, }; /* button definitions */ @@ -241,6 +241,8 @@ static void seturgent(Client *c, int urg); static void setviewport(void); static void showhide(Client *c); static void sigchld(int unused); +static void sighup(int unused); +static void sigterm(int unused); static void spawn(const Arg *arg); static void swallow(Client *p, Client *c); static Client *swallowingclient(Window w); @@ -301,6 +303,7 @@ static void (*handler[LASTEvent]) (XEvent *) = { [UnmapNotify] = unmapnotify }; static Atom wmatom[WMLast], netatom[NetLast], motifatom; +static int restart = 0; static int running = 1; static Cur *cursor[CurLast]; static Clr **scheme; @@ -1461,6 +1464,7 @@ quit(const Arg *arg) } } + if(arg->i) restart = 1; running = 0; } @@ -1798,6 +1802,9 @@ setup(void) /* clean up any zombies immediately */ sigchld(0); + signal(SIGHUP, sighup); + signal(SIGTERM, sigterm); + /* init screen */ screen = DefaultScreen(dpy); sw = DisplayWidth(dpy, screen); @@ -1929,6 +1936,20 @@ sigchld(int unused) } 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) { if (arg->v == dmenucmd) @@ -2707,6 +2728,7 @@ main(int argc, char *argv[]) #endif /* __OpenBSD__ */ scan(); run(); + if(restart) execvp(argv[0], argv); cleanup(); XCloseDisplay(dpy); return EXIT_SUCCESS; |