restartsig patch

- Apply restartsig patch
- Add keybinding for restarting dwm
- Update man page with keybinding
- Update README with patch link
This commit is contained in:
Sravan Balaji
2020-08-30 15:29:14 -04:00
parent e7ece2aaba
commit e896c3107e
4 changed files with 89 additions and 55 deletions

View File

@@ -56,6 +56,7 @@ and (re)compiling the source code.
* [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
* [gridmode](https://dwm.suckless.org/patches/gridmode/)
* [movestack](https://dwm.suckless.org/patches/movestack/)
* [restartsig](https://dwm.suckless.org/patches/restartsig/)
* [ru_gaps](https://dwm.suckless.org/patches/ru_gaps/)
* [systray](https://dwm.suckless.org/patches/systray/)

111
config.h
View File

@@ -88,61 +88,62 @@ static const char *flameshotcmd[] = { "flameshot", "gui", NULL };
/* key definitions */
static Key keys[] = {
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = rofiruncmd} },
{ MODKEY, XK_c, spawn, {.v = roficlipcmd} },
{ MODKEY|ShiftMask, XK_n, spawn, {.v = deaddcmd} },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd} },
{ MODKEY|ShiftMask, XK_s, spawn, {.v = sleepcmd} },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd} },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1} },
{ MODKEY, XK_k, focusstack, {.i = -1} },
{ MODKEY, XK_i, incnmaster, {.i = +1} },
{ MODKEY, XK_d, incnmaster, {.i = -1} },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1} },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_g, setlayout, {.v = &layouts[5]} },
{ MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
{ MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0} },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0} },
{ MODKEY, XK_comma, focusmon, {.i = -1} },
{ MODKEY, XK_period, focusmon, {.i = +1} },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1} },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1} },
{ MODKEY, XK_minus, setgaps, {.i = -5 } },
{ MODKEY, XK_equal, setgaps, {.i = +5 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvolcmd} },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevolcmd} },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvolcmd} },
{ 0, XF86XK_AudioPlay, spawn, {.v = playerplaypausecmd} },
{ 0, XF86XK_AudioNext, spawn, {.v = playernextcmd} },
{ 0, XF86XK_AudioPrev, spawn, {.v = playerprevcmd} },
{ 0, XK_Print, spawn, {.v = flameshotcmd} },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
/* modifier key function argument */
{ MODKEY, XK_p, spawn, {.v = rofiruncmd} },
{ MODKEY, XK_c, spawn, {.v = roficlipcmd} },
{ MODKEY|ShiftMask, XK_n, spawn, {.v = deaddcmd} },
{ MODKEY|ShiftMask, XK_l, spawn, {.v = lockcmd} },
{ MODKEY|ShiftMask, XK_s, spawn, {.v = sleepcmd} },
{ MODKEY|ShiftMask, XK_Return, spawn, {.v = termcmd} },
{ MODKEY, XK_b, togglebar, {0} },
{ MODKEY, XK_j, focusstack, {.i = +1} },
{ MODKEY, XK_k, focusstack, {.i = -1} },
{ MODKEY, XK_i, incnmaster, {.i = +1} },
{ MODKEY, XK_d, incnmaster, {.i = -1} },
{ MODKEY, XK_h, setmfact, {.f = -0.05} },
{ MODKEY, XK_l, setmfact, {.f = +0.05} },
{ MODKEY|ShiftMask, XK_j, movestack, {.i = +1} },
{ MODKEY|ShiftMask, XK_k, movestack, {.i = -1} },
{ MODKEY, XK_Return, zoom, {0} },
{ MODKEY, XK_Tab, view, {0} },
{ MODKEY|ShiftMask, XK_c, killclient, {0} },
{ MODKEY, XK_t, setlayout, {.v = &layouts[0]} },
{ MODKEY, XK_f, setlayout, {.v = &layouts[1]} },
{ MODKEY, XK_m, setlayout, {.v = &layouts[2]} },
{ MODKEY, XK_u, setlayout, {.v = &layouts[3]} },
{ MODKEY, XK_o, setlayout, {.v = &layouts[4]} },
{ MODKEY, XK_g, setlayout, {.v = &layouts[5]} },
{ MODKEY|ControlMask, XK_comma, cyclelayout, {.i = -1 } },
{ MODKEY|ControlMask, XK_period, cyclelayout, {.i = +1 } },
{ MODKEY, XK_space, setlayout, {0} },
{ MODKEY|ShiftMask, XK_space, togglefloating, {0} },
{ MODKEY, XK_0, view, {.ui = ~0} },
{ MODKEY|ShiftMask, XK_0, tag, {.ui = ~0} },
{ MODKEY, XK_comma, focusmon, {.i = -1} },
{ MODKEY, XK_period, focusmon, {.i = +1} },
{ MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1} },
{ MODKEY|ShiftMask, XK_period, tagmon, {.i = +1} },
{ MODKEY, XK_minus, setgaps, {.i = -5 } },
{ MODKEY, XK_equal, setgaps, {.i = +5 } },
{ MODKEY|ShiftMask, XK_equal, setgaps, {.i = 0 } },
{ 0, XF86XK_AudioLowerVolume, spawn, {.v = downvolcmd} },
{ 0, XF86XK_AudioMute, spawn, {.v = mutevolcmd} },
{ 0, XF86XK_AudioRaiseVolume, spawn, {.v = upvolcmd} },
{ 0, XF86XK_AudioPlay, spawn, {.v = playerplaypausecmd} },
{ 0, XF86XK_AudioNext, spawn, {.v = playernextcmd} },
{ 0, XF86XK_AudioPrev, spawn, {.v = playerprevcmd} },
{ 0, XK_Print, spawn, {.v = flameshotcmd} },
TAGKEYS( XK_1, 0)
TAGKEYS( XK_2, 1)
TAGKEYS( XK_3, 2)
TAGKEYS( XK_4, 3)
TAGKEYS( XK_5, 4)
TAGKEYS( XK_6, 5)
TAGKEYS( XK_7, 6)
TAGKEYS( XK_8, 7)
TAGKEYS( XK_9, 8)
{ MODKEY|ShiftMask, XK_q, quit, {0} },
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
};
/* button definitions */

10
dwm.1
View File

@@ -193,6 +193,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
@@ -218,6 +221,13 @@ This file is started before any autostart.sh; dwm waits for its termination.
.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 rofi (1),
.BR st (1)

22
dwm.c
View File

@@ -240,6 +240,8 @@ static void setup(void);
static void seturgent(Client *c, int urg);
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 Monitor *systraytomon(Monitor *m);
static void tag(const Arg *arg);
@@ -316,6 +318,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;
@@ -1456,6 +1459,7 @@ propertynotify(XEvent *e)
void
quit(const Arg *arg)
{
if(arg->i) restart = 1;
running = 0;
}
@@ -1900,6 +1904,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);
@@ -2009,6 +2016,20 @@ sigchld(int unused)
while (0 < waitpid(-1, NULL, WNOHANG));
}
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)
{
@@ -2691,6 +2712,7 @@ main(int argc, char *argv[])
runautostart();
run();
runautoquit();
if(restart) execvp(argv[0], argv);
cleanup();
XCloseDisplay(dpy);
return EXIT_SUCCESS;