aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-10 20:30:09 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-10 20:30:09 +0530
commit30b203af5d6f35c5f94fb3a65845432cde014347 (patch)
tree55663a7a3c0737d34403fcca3a64c46dacf8c08a
parentbd7e23dff2c22e1133ec7908f689b9e7b8d5704a (diff)
patched dwm-focusadjacenttag-6.3.diff
-rw-r--r--apply.orig0
-rw-r--r--config.def.h16
-rw-r--r--dwm.112
-rw-r--r--dwm.c48
-rw-r--r--patches/dwm-focusadjacenttag-6.3.diff115
5 files changed, 191 insertions, 0 deletions
diff --git a/apply.orig b/apply.orig
deleted file mode 100644
index e69de29..0000000
--- a/apply.orig
+++ /dev/null
diff --git a/config.def.h b/config.def.h
index 15dde7c..604be99 100644
--- a/config.def.h
+++ b/config.def.h
@@ -55,6 +55,16 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
static const char *dmenucmd[] = { "dmenu_run", NULL };
static const char *termcmd[] = { "open_terminal", NULL };
+void shiftAndViewLeft(const Arg *arg) {
+ tagtoleft(arg);
+ viewtoleft(arg);
+}
+
+void shiftAndViewRight(const Arg *arg) {
+ tagtoright(arg);
+ viewtoright(arg);
+}
+
static const Key keys[] = {
/* modifier key function argument */
@@ -88,6 +98,12 @@ static const Key keys[] = {
// { MODKEY, XK_0, view, {.ui = ~0 } },
// { MODKEY|ShiftMask, XK_0, tag, {.ui = ~0 } },
+ /* viewing and moving to adjacent tags */
+ { MODKEY, XK_h, viewtoleft, {0} },
+ { MODKEY, XK_l, viewtoright, {0} },
+ { MODKEY|ShiftMask, XK_h, shiftAndViewLeft, {0} },
+ { MODKEY|ShiftMask, XK_l, shiftAndViewRight, {0} },
+
/* multi monitor stuff */
/* TODO: have bindings to move and focus at the same time */
diff --git a/dwm.1 b/dwm.1
index ddc8321..6d8cd6d 100644
--- a/dwm.1
+++ b/dwm.1
@@ -77,6 +77,18 @@ Send focused window to previous screen, if any.
.B Mod1\-Shift\-.
Send focused window to next screen, if any.
.TP
+.B Mod1\-Right
+Focus tag on the right, if any.
+.TP
+.B Mod1\-Left
+Focus tag on the left, if any.
+.TP
+.B Mod1\-Shift\-Right
+Send focused window to tag on the right, if any.
+.TP
+.B Mod1\-Shift\-Left
+Send focused window to tag on the left, if any.
+.TP
.B Mod1\-b
Toggles bar on and off.
.TP
diff --git a/dwm.c b/dwm.c
index 78f6996..a3d9254 100644
--- a/dwm.c
+++ b/dwm.c
@@ -213,6 +213,8 @@ static void showhide(Client *c);
static void spawn(const Arg *arg);
static void tag(const Arg *arg);
static void tagmon(const Arg *arg);
+static void tagtoleft(const Arg *arg);
+static void tagtoright(const Arg *arg);
static void tile(Monitor *m);
static void togglebar(const Arg *arg);
static void togglefloating(const Arg *arg);
@@ -232,6 +234,8 @@ static void updatetitle(Client *c);
static void updatewindowtype(Client *c);
static void updatewmhints(Client *c);
static void view(const Arg *arg);
+static void viewtoleft(const Arg *arg);
+static void viewtoright(const Arg *arg);
static Client *wintoclient(Window w);
static Monitor *wintomon(Window w);
static int xerror(Display *dpy, XErrorEvent *ee);
@@ -1876,6 +1880,28 @@ tagmon(const Arg *arg)
}
void
+tagtoleft(const Arg *arg) {
+ if(selmon->sel != NULL
+ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] > 1) {
+ selmon->sel->tags >>= 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
+tagtoright(const Arg *arg) {
+ if(selmon->sel != NULL
+ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
+ selmon->sel->tags <<= 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
tile(Monitor *m)
{
unsigned int i, n, h, mw, my, ty;
@@ -2260,6 +2286,28 @@ view(const Arg *arg)
arrange(selmon);
}
+void
+viewtoleft(const Arg *arg) {
+ if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] > 1) {
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
+void
+viewtoright(const Arg *arg) {
+ if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
+ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
+ selmon->seltags ^= 1; /* toggle sel tagset */
+ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
+ focus(NULL);
+ arrange(selmon);
+ }
+}
+
Client *
wintoclient(Window w)
{
diff --git a/patches/dwm-focusadjacenttag-6.3.diff b/patches/dwm-focusadjacenttag-6.3.diff
new file mode 100644
index 0000000..142b57e
--- /dev/null
+++ b/patches/dwm-focusadjacenttag-6.3.diff
@@ -0,0 +1,115 @@
+diff -up a/config.def.h b/config.def.h
+--- a/config.def.h 2014-06-23 18:04:29.536917000 +0200
++++ b/config.def.h 2014-06-24 08:15:51.857173332 +0200
+@@ -74,6 +74,10 @@ static Key keys[] = {
+ { MODKEY, XK_period, focusmon, {.i = +1 } },
+ { MODKEY|ShiftMask, XK_comma, tagmon, {.i = -1 } },
+ { MODKEY|ShiftMask, XK_period, tagmon, {.i = +1 } },
++ { MODKEY, XK_Left, viewtoleft, {0} },
++ { MODKEY, XK_Right, viewtoright, {0} },
++ { MODKEY|ShiftMask, XK_Left, tagtoleft, {0} },
++ { MODKEY|ShiftMask, XK_Right, tagtoright, {0} },
+ TAGKEYS( XK_1, 0)
+ TAGKEYS( XK_2, 1)
+ TAGKEYS( XK_3, 2)
+diff -up a/dwm.1 b/dwm.1
+--- a/dwm.1 2014-06-23 18:04:29.532917821 +0200
++++ b/dwm.1 2014-06-23 21:52:54.095867809 +0200
+@@ -71,6 +71,18 @@ Send focused window to previous screen,
+ .B Mod1\-Shift\-.
+ Send focused window to next screen, if any.
+ .TP
++.B Mod1\-Right
++Focus tag on the right, if any.
++.TP
++.B Mod1\-Left
++Focus tag on the left, if any.
++.TP
++.B Mod1\-Shift\-Right
++Send focused window to tag on the right, if any.
++.TP
++.B Mod1\-Shift\-Left
++Send focused window to tag on the left, if any.
++.TP
+ .B Mod1\-b
+ Toggles bar on and off.
+ .TP
+diff -up a/dwm.c b/dwm.c
+--- a/dwm.c 2014-06-23 18:04:29.532917821 +0200
++++ b/dwm.c 2014-06-24 08:17:40.921714154 +0200
+@@ -226,6 +226,8 @@ static void sigchld(int unused);
+ static void spawn(const Arg *arg);
+ static void tag(const Arg *arg);
+ static void tagmon(const Arg *arg);
++static void tagtoleft(const Arg *arg);
++static void tagtoright(const Arg *arg);
+ static void tile(Monitor *);
+ static void togglebar(const Arg *arg);
+ static void togglefloating(const Arg *arg);
+@@ -245,6 +247,8 @@ static void updatewindowtype(Client *c);
+ static void updatewindowtype(Client *c);
+ static void updatewmhints(Client *c);
+ static void view(const Arg *arg);
++static void viewtoleft(const Arg *arg);
++static void viewtoright(const Arg *arg);
+ static Client *wintoclient(Window w);
+ static Monitor *wintomon(Window w);
+ static int xerror(Display *dpy, XErrorEvent *ee);
+@@ -1690,6 +1694,28 @@ tagmon(const Arg *arg) {
+ sendmon(selmon->sel, dirtomon(arg->i));
+ }
+
++void
++tagtoleft(const Arg *arg) {
++ if(selmon->sel != NULL
++ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
++ && selmon->tagset[selmon->seltags] > 1) {
++ selmon->sel->tags >>= 1;
++ focus(NULL);
++ arrange(selmon);
++ }
++}
++
++void
++tagtoright(const Arg *arg) {
++ if(selmon->sel != NULL
++ && __builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
++ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
++ selmon->sel->tags <<= 1;
++ focus(NULL);
++ arrange(selmon);
++ }
++}
++
+ void
+ tile(Monitor *m)
+ {
+@@ -2052,6 +2078,28 @@ view(const Arg *arg) {
+ arrange(selmon);
+ }
+
++void
++viewtoleft(const Arg *arg) {
++ if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
++ && selmon->tagset[selmon->seltags] > 1) {
++ selmon->seltags ^= 1; /* toggle sel tagset */
++ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] >> 1;
++ focus(NULL);
++ arrange(selmon);
++ }
++}
++
++void
++viewtoright(const Arg *arg) {
++ if(__builtin_popcount(selmon->tagset[selmon->seltags] & TAGMASK) == 1
++ && selmon->tagset[selmon->seltags] & (TAGMASK >> 1)) {
++ selmon->seltags ^= 1; /* toggle sel tagset */
++ selmon->tagset[selmon->seltags] = selmon->tagset[selmon->seltags ^ 1] << 1;
++ focus(NULL);
++ arrange(selmon);
++ }
++}
++
+ Client *
+ wintoclient(Window w)
+ {