Adding restartsig and emptyview patches

This commit is contained in:
bakkeby 2019-10-02 23:22:04 +02:00
parent 37b1b54ab9
commit 0a23ed6efd
8 changed files with 86 additions and 0 deletions

View File

@ -13,6 +13,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
2019-10-02 - Added restartsig and emptyview patch
2019-10-01 - Added leftlayout, fullscreen, holdbar and unfloatvisible patches
2019-09-30 - Replaced flextile with flextile-deluxe, refactored monitor rules to support predetermined layouts per tag
@ -86,6 +88,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [cyclelayouts](https://dwm.suckless.org/patches/cyclelayouts/)
- lets you cycle through all your layouts
- [emptyview](https://dwm.suckless.org/patches/emptyview/)
- allows no tag at all to be selected
- dwm will start with no tag selected and when a client with no tag rule is started and no tag is selected then it will be opened on the first tag
- [ewmhtags](https://dwm.suckless.org/patches/ewmhtags/)
- adds EWMH support for \_NET_NUMBER_OF_DESKTOPS, \_NET_CURRENT_DESKTOP, \_NET_DESKTOP_NAMES and \_NET_DESKTOP_VIEWPORT, which allows for compatibility with other bars and programs that request workspace information, e.g. polybar's xworkspaces module
@ -132,6 +138,10 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- by default, windows only resize from the bottom right corner
- with this patch the mouse is warped to the nearest corner and you resize from there
- [restartsig](https://dwm.suckless.org/patches/restartsig/)
- adds a keyboard shortcut to restart dwm or alternatively by using kill -HUP dwmpid
- additionally dwm can quit cleanly by using kill -TERM dwmpid
- [rotatestack](https://dwm.suckless.org/patches/rotatestack/)
- let's you rotate through the stack using keyboard shortcuts

View File

@ -358,6 +358,9 @@ static Key keys[] = {
{ MODKEY|ShiftMask, XK_r, self_restart, {0} },
#endif // SELFRESTART_PATCH
{ MODKEY|ShiftMask, XK_q, quit, {0} },
#if RESTARTSIG_PATCH
{ MODKEY|ControlMask|ShiftMask, XK_q, quit, {1} },
#endif // RESTARTSIG_PATCH
#if HOLDBAR_PATCH
{ 0, HOLDKEY, holdbar, {0} },
#endif // HOLDBAR_PATCH

35
dwm.c
View File

@ -483,7 +483,13 @@ applyrules(Client *c)
XFree(ch.res_class);
if (ch.res_name)
XFree(ch.res_name);
#if EMPTYVIEW_PATCH
if(c->tags & TAGMASK) c->tags = c->tags & TAGMASK;
else if(c->mon->tagset[c->mon->seltags]) c->tags = c->mon->tagset[c->mon->seltags];
else c->tags = 1;
#else
c->tags = c->tags & TAGMASK ? c->tags & TAGMASK : c->mon->tagset[c->mon->seltags];
#endif // EMPTYVIEW_PATCH
}
int
@ -976,7 +982,11 @@ createmon(void)
#endif // MONITOR_RULES_PATCH
m = ecalloc(1, sizeof(Monitor));
#if EMPTYVIEW_PATCH
m->tagset[0] = m->tagset[1] = 0;
#else
m->tagset[0] = m->tagset[1] = 1;
#endif // EMPTYVIEW_PATCH
m->mfact = mfact;
m->nmaster = nmaster;
#if FLEXTILE_DELUXE_LAYOUT
@ -1968,6 +1978,10 @@ propertynotify(XEvent *e)
void
quit(const Arg *arg)
{
#if RESTARTSIG_PATCH
if (arg->i)
restart = 1;
#endif // RESTARTSIG_PATCH
running = 0;
}
@ -2191,7 +2205,11 @@ sendmon(Client *c, Monitor *m)
detach(c);
detachstack(c);
c->mon = m;
#if EMPTYVIEW_PATCH
c->tags = (m->tagset[m->seltags] ? m->tagset[m->seltags] : 1);
#else
c->tags = m->tagset[m->seltags]; /* assign tags of target monitor */
#endif // EMPTYVIEW_PATCH
#if ATTACHABOVE_PATCH || ATTACHASIDE_PATCH || ATTACHBELOW_PATCH || ATTACHBOTTOM_PATCH
attachx(c);
#else
@ -2388,6 +2406,11 @@ setup(void)
/* clean up any zombies immediately */
sigchld(0);
#if RESTARTSIG_PATCH
signal(SIGHUP, sighup);
signal(SIGTERM, sigterm);
#endif // RESTARTSIG_PATCH
/* init screen */
screen = DefaultScreen(dpy);
sw = DisplayWidth(dpy, screen);
@ -2693,7 +2716,9 @@ toggleview(const Arg *arg)
int i;
#endif // PERTAG_PATCH
#if !EMPTYVIEW_PATCH
if (newtagset) {
#endif // EMPTYVIEW_PATCH
selmon->tagset[selmon->seltags] = newtagset;
#if PERTAG_PATCH
@ -2721,7 +2746,9 @@ toggleview(const Arg *arg)
#endif // PERTAG_PATCH
focus(NULL);
arrange(selmon);
#if !EMPTYVIEW_PATCH
}
#endif // EMPTYVIEW_PATCH
#if EWMHTAGS_PATCH
updatecurrentdesktop();
#endif // EWMHTAGS_PATCH
@ -3072,7 +3099,11 @@ updatewmhints(Client *c)
void
view(const Arg *arg)
{
#if EMPTYVIEW_PATCH
if (arg->ui && (arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
#else
if ((arg->ui & TAGMASK) == selmon->tagset[selmon->seltags])
#endif // EMPTYVIEW_PATCH
return;
selmon->seltags ^= 1; /* toggle sel tagset */
#if PERTAG_PATCH
@ -3247,6 +3278,10 @@ main(int argc, char *argv[])
runAutostart();
#endif
run();
#if RESTARTSIG_PATCH
if (restart)
execvp(argv[0], argv);
#endif // RESTARTSIG_PATCH
cleanup();
XCloseDisplay(dpy);
return EXIT_SUCCESS;

View File

@ -54,6 +54,10 @@
#include "push.c"
#endif
#if RESTARTSIG_PATCH
#include "restartsig.c"
#endif
#if ROTATESTACK_PATCH
#include "rotatestack.c"
#endif

View File

@ -54,6 +54,10 @@
#include "push.h"
#endif
#if RESTARTSIG_PATCH
#include "restartsig.h"
#endif
#if ROTATESTACK_PATCH
#include "rotatestack.h"
#endif

15
patch/restartsig.c Normal file
View File

@ -0,0 +1,15 @@
static int restart = 0;
void
sighup(int unused)
{
Arg a = {.i = 1};
quit(&a);
}
void
sigterm(int unused)
{
Arg a = {.i = 0};
quit(&a);
}

2
patch/restartsig.h Normal file
View File

@ -0,0 +1,2 @@
static void sighup(int unused);
static void sigterm(int unused);

View File

@ -110,6 +110,13 @@
*/
#define CYCLELAYOUTS_PATCH 0
/* This patch allows no tag at all to be selected. The result is that dwm will start with
* no tag selected and when you start a client with no tag rule and no tag selected then
* it will be opened on the first tag.
* https://dwm.suckless.org/patches/emptyview/
*/
#define EMPTYVIEW_PATCH 0
/* Adds EWMH support for _NET_NUMBER_OF_DESKTOPS, _NET_CURRENT_DESKTOP, _NET_DESKTOP_NAMES
* and _NET_DESKTOP_VIEWPORT, which allows for compatibility with other bars and programs
* that request workspace information. For example polybar's xworkspaces module.
@ -206,6 +213,12 @@
*/
#define RESIZECORNERS_PATCH 0
/* Adds a keyboard shortcut to restart dwm or alternatively by using kill -HUP dwmpid.
* Additionally dwm can quit cleanly by using kill -TERM dwmpid.
* https://dwm.suckless.org/patches/restartsig/
*/
#define RESTARTSIG_PATCH 0
/* This patch let's you rotate through the stack using keyboard shortcuts.
* https://dwm.suckless.org/patches/rotatestack/
*/