summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rw-r--r--config.def.h6
-rw-r--r--patch/include.c3
-rw-r--r--patch/include.h3
-rw-r--r--patch/swaptags.c22
-rw-r--r--patch/swaptags.h1
-rw-r--r--patches.def.h6
7 files changed, 44 insertions, 2 deletions
diff --git a/README.md b/README.md
index 02076cf..ed9cdad 100644
--- a/README.md
+++ b/README.md
@@ -15,6 +15,8 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
### Changelog:
+2020-02-11 - Added swaptags patch
+
2020-02-09 - Added alternative scratchpad patch
2020-02-02 - Added fsignal and transferall patches
@@ -313,6 +315,9 @@ Refer to [https://dwm.suckless.org/](https://dwm.suckless.org/) for details on t
- [swapfocus](https://dwm.suckless.org/patches/swapfocus/)
- this patch depends on the pertag patch and makes it possible to switch focus with a single shortcut (mod-s) instead of having to think if you should use mod-j or mod-k for reaching the previously used window
+ - [swaptags](https://dwm.suckless.org/patches/swaptags/)
+ - allows swapping the contents of the currently selected tag with another tag by using keyboard shortcuts
+
- [switchcol](https://dwm.suckless.org/patches/switchcol/)
- allows you to switch focus between the master and stack columns using a single keybinding
diff --git a/config.def.h b/config.def.h
index ebde903..99005f2 100644
--- a/config.def.h
+++ b/config.def.h
@@ -514,13 +514,15 @@ static const Layout layouts[] = {
{ MODKEY, KEY, comboview, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, combotag, {.ui = 1 << TAG} }, \
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
+ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \
+ { MODKEY|Mod4Mask|ShiftMask, KEY, swaptags, {.ui = 1 << TAG} },
#else
#define TAGKEYS(KEY,TAG) \
{ MODKEY, KEY, view, {.ui = 1 << TAG} }, \
{ MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \
{ MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \
- { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} },
+ { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \
+ { MODKEY|Mod4Mask|ShiftMask, KEY, swaptags, {.ui = 1 << TAG} },
#endif // COMBO_PATCH
#if HOLDBAR_PATCH
diff --git a/patch/include.c b/patch/include.c
index ef71088..4ed46cd 100644
--- a/patch/include.c
+++ b/patch/include.c
@@ -113,6 +113,9 @@
#if SWAPFOCUS_PATCH && PERTAG_PATCH
#include "swapfocus.c"
#endif
+#if SWAPTAGS_PATCH
+#include "swaptags.c"
+#endif
#if SWITCHCOL_PATCH
#include "switchcol.c"
#endif
diff --git a/patch/include.h b/patch/include.h
index 62ecd46..ba906a5 100644
--- a/patch/include.h
+++ b/patch/include.h
@@ -113,6 +113,9 @@
#if SWAPFOCUS_PATCH && PERTAG_PATCH
#include "swapfocus.h"
#endif
+#if SWAPTAGS_PATCH
+#include "swaptags.h"
+#endif
#if SWITCHCOL_PATCH
#include "switchcol.h"
#endif
diff --git a/patch/swaptags.c b/patch/swaptags.c
new file mode 100644
index 0000000..c43a83f
--- /dev/null
+++ b/patch/swaptags.c
@@ -0,0 +1,22 @@
+void
+swaptags(const Arg *arg)
+{
+ unsigned int newtag = arg->ui & TAGMASK;
+ unsigned int curtag = selmon->tagset[selmon->seltags];
+
+ if (newtag == curtag || !curtag || (curtag & (curtag-1)))
+ return;
+
+ for (Client *c = selmon->clients; c != NULL; c = c->next) {
+ if ((c->tags & newtag) || (c->tags & curtag))
+ c->tags ^= curtag ^ newtag;
+
+ if (!c->tags)
+ c->tags = newtag;
+ }
+
+ selmon->tagset[selmon->seltags] = newtag;
+
+ focus(NULL);
+ arrange(selmon);
+} \ No newline at end of file
diff --git a/patch/swaptags.h b/patch/swaptags.h
new file mode 100644
index 0000000..150fcce
--- /dev/null
+++ b/patch/swaptags.h
@@ -0,0 +1 @@
+static void swaptags(const Arg *arg); \ No newline at end of file
diff --git a/patches.def.h b/patches.def.h
index 73b7822..8e49810 100644
--- a/patches.def.h
+++ b/patches.def.h
@@ -468,6 +468,12 @@
*/
#define SWAPFOCUS_PATCH 0
+/* This patch allows swapping the contents of the currently selected tag with another tag using
+ * keyboard shortcuts.
+ * https://dwm.suckless.org/patches/swaptags/
+ */
+#define SWAPTAGS_PATCH 0
+
/* Switch focus between the master and stack columns using a single keybinding.
* https://dwm.suckless.org/patches/switchcol/
*/