focusmon_n will change focus to a specific monitor in the stack. 0 thru
n.

tagmon_n will move the selected window to the specific monitor in the
stack. 0 thru n.
---
 dwm.c | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)

diff --git a/dwm.c b/dwm.c
index 664c527..85749ae 100644
--- a/dwm.c
+++ b/dwm.c
@@ -168,6 +168,7 @@ static void expose(XEvent *e);
 static void focus(Client *c);
 static void focusin(XEvent *e);
 static void focusmon(const Arg *arg);
+static void focusmon_n(const Arg *arg);
 static void focusstack(const Arg *arg);
 static Atom getatomprop(Client *c, Atom prop);
 static int getrootptr(int *x, int *y);
@@ -209,6 +210,7 @@ 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 tagmon_n(const Arg *arg);
 static void tile(Monitor *);
 static void togglebar(const Arg *arg);
 static void togglefloating(const Arg *arg);
@@ -830,6 +832,20 @@ focusmon(const Arg *arg)
        focus(NULL);
 }
 
+/* Set monitor to specific monitor #0-n */
+void focusmon_n(const Arg *arg)
+{
+       Monitor *m;
+       int i;
+
+       for(i=0, m=mons; i < arg->i && m->next; i++, m=m->next);
+       if (m == selmon)
+               return;
+       unfocus(selmon->sel, 0);
+       selmon = m;
+       focus(NULL);
+}
+
 void
 focusstack(const Arg *arg)
 {
@@ -1671,6 +1687,18 @@ tagmon(const Arg *arg)
        sendmon(selmon->sel, dirtomon(arg->i));
 }
 
+/* Move window to specific monitor #0-n */
+void tagmon_n(const Arg *arg)
+{
+       Monitor *m;
+       int i;
+
+       if (!selmon->sel)
+               return;
+       for(i=0, m=mons; i < arg->i && m->next; i++, m=m->next);
+       sendmon(selmon->sel, m);
+}
+
 void
 tile(Monitor *m)
 {
-- 
2.28.0


Reply via email to