accessnthmon.diff (2695B)
1 diff --git a/config.def.h b/config.def.h 2 index 1c0b587..8595a71 100644 3 --- a/config.def.h 4 +++ b/config.def.h 5 @@ -49,7 +49,10 @@ static const Layout layouts[] = { 6 { MODKEY, KEY, view, {.ui = 1 << TAG} }, \ 7 { MODKEY|ControlMask, KEY, toggleview, {.ui = 1 << TAG} }, \ 8 { MODKEY|ShiftMask, KEY, tag, {.ui = 1 << TAG} }, \ 9 - { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, 10 + { MODKEY|ControlMask|ShiftMask, KEY, toggletag, {.ui = 1 << TAG} }, \ 11 + { ALTMOD, KEY, focusnthmon, {.i = TAG } }, \ 12 + { ALTMOD|ShiftMask, KEY, tagnthmon, {.i = TAG } }, 13 + 14 15 /* helper for spawning shell commands in the pre dwm-5.0 fashion */ 16 #define SHCMD(cmd) { .v = (const char*[]){ "/bin/sh", "-c", cmd, NULL } } 17 diff --git a/dwm.c b/dwm.c 18 index b0b3466..96fa0bd 100644 19 --- a/dwm.c 20 +++ b/dwm.c 21 @@ -161,6 +161,7 @@ static void destroynotify(XEvent *e); 22 static void detach(Client *c); 23 static void detachstack(Client *c); 24 static Monitor *dirtomon(int dir); 25 +static Monitor *numtomon(int num); 26 static void drawbar(Monitor *m); 27 static void drawbars(void); 28 static void enternotify(XEvent *e); 29 @@ -168,6 +169,7 @@ static void expose(XEvent *e); 30 static void focus(Client *c); 31 static void focusin(XEvent *e); 32 static void focusmon(const Arg *arg); 33 +static void focusnthmon(const Arg *arg); 34 static void focusstack(const Arg *arg); 35 static Atom getatomprop(Client *c, Atom prop); 36 static int getrootptr(int *x, int *y); 37 @@ -209,6 +211,7 @@ static void sigchld(int unused); 38 static void spawn(const Arg *arg); 39 static void tag(const Arg *arg); 40 static void tagmon(const Arg *arg); 41 +static void tagnthmon(const Arg *arg); 42 static void tile(Monitor *); 43 static void togglebar(const Arg *arg); 44 static void togglefloating(const Arg *arg); 45 @@ -693,6 +696,18 @@ dirtomon(int dir) 46 return m; 47 } 48 49 +Monitor * 50 +numtomon(int num) 51 +{ 52 + Monitor *m = NULL; 53 + int i = 0; 54 + 55 + for(m = mons, i=0; m->next && i < num; m = m->next){ 56 + i++; 57 + } 58 + return m; 59 +} 60 + 61 void 62 drawbar(Monitor *m) 63 { 64 @@ -830,6 +845,21 @@ focusmon(const Arg *arg) 65 focus(NULL); 66 } 67 68 +void 69 +focusnthmon(const Arg *arg) 70 +{ 71 + Monitor *m; 72 + 73 + if (!mons->next) 74 + return; 75 + 76 + if ((m = numtomon(arg->i)) == selmon) 77 + return; 78 + unfocus(selmon->sel, 0); 79 + selmon = m; 80 + focus(NULL); 81 +} 82 + 83 void 84 focusstack(const Arg *arg) 85 { 86 @@ -1671,6 +1701,14 @@ tagmon(const Arg *arg) 87 sendmon(selmon->sel, dirtomon(arg->i)); 88 } 89 90 +void 91 +tagnthmon(const Arg *arg) 92 +{ 93 + if (!selmon->sel || !mons->next) 94 + return; 95 + sendmon(selmon->sel, numtomon(arg->i)); 96 +} 97 + 98 void 99 tile(Monitor *m) 100 {