diff --git a/README.md b/README.md index 484e223..917fb23 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/config.def.h b/config.def.h index bf55176..ce6a6ca 100644 --- a/config.def.h +++ b/config.def.h @@ -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 diff --git a/dwm.c b/dwm.c index 55b89e6..7fed237 100644 --- a/dwm.c +++ b/dwm.c @@ -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; diff --git a/patch/include.c b/patch/include.c index bb41382..920f7ff 100644 --- a/patch/include.c +++ b/patch/include.c @@ -54,6 +54,10 @@ #include "push.c" #endif +#if RESTARTSIG_PATCH +#include "restartsig.c" +#endif + #if ROTATESTACK_PATCH #include "rotatestack.c" #endif diff --git a/patch/include.h b/patch/include.h index d19423e..67578c7 100644 --- a/patch/include.h +++ b/patch/include.h @@ -54,6 +54,10 @@ #include "push.h" #endif +#if RESTARTSIG_PATCH +#include "restartsig.h" +#endif + #if ROTATESTACK_PATCH #include "rotatestack.h" #endif diff --git a/patch/restartsig.c b/patch/restartsig.c new file mode 100644 index 0000000..0bef576 --- /dev/null +++ b/patch/restartsig.c @@ -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); +} \ No newline at end of file diff --git a/patch/restartsig.h b/patch/restartsig.h new file mode 100644 index 0000000..5a08c39 --- /dev/null +++ b/patch/restartsig.h @@ -0,0 +1,2 @@ +static void sighup(int unused); +static void sigterm(int unused); \ No newline at end of file diff --git a/patches.h b/patches.h index d43169e..55c7165 100644 --- a/patches.h +++ b/patches.h @@ -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/ */