[dev] Re: [dwm] [patch] Focus on a window by number

From: Marshall Mason <marshallmason2_AT_gmail.com>
Date: Sun, 25 Nov 2012 11:02:54 -0800

It looks like the attachment I sent via email didn't show up in the
mailing list. I'll try to edit the wiki. Meanwhile, here's the patch:

Only in dwm-6.0-orig: dwm-6.0
diff -up dwm-6.0-orig/dwm.c dwm-6.0-mod/dwm.c
--- dwm-6.0-orig/dwm.c 2011-12-19 07:02:46.000000000 -0800
+++ dwm-6.0-mod/dwm.c 2012-11-24 13:07:00.253914572 -0800
_AT_@ -185,6 +185,7 @@ static void expose(XEvent *e);
 static void focus(Client *c);
 static void focusin(XEvent *e);
 static void focusmon(const Arg *arg);
+static void focusnumber(const Arg *arg);
 static void focusstack(const Arg *arg);
 static unsigned long getcolor(const char *colstr);
 static Bool getrootptr(int *x, int *y);
_AT_@ -886,6 +887,25 @@ focusmon(const Arg *arg) {
 }

 void
+focusnumber(const Arg *arg) {
+ Client *c = NULL;
+ int cnum = 1;
+
+ if(!selmon->sel)
+ return;
+ if(arg->i <= 0)
+ return;
+
+ for(c = selmon->clients; c && cnum < arg->i; c = c->next)
+ if(ISVISIBLE(c))
+ cnum++;
+ if(c) {
+ focus(c);
+ restack(selmon);
+ }
+}
+
+void
 focusstack(const Arg *arg) {
         Client *c = NULL, *i;


On 11/24/12, Marshall Mason <marshallmason2_AT_gmail.com> wrote:
> I just started using dwm, and I'm starting to get used to the tiled
> way of doing things. In Openbox, I found a little utility program that
> allowed me to jump to the exact window I want, by number. It's
> incredibly useful when there are a lot of windows open, rather than
> cycling through them with MODKEY+j. Just as you can jump to a tag with
> MODKEY+#, this patch allows you to jump to a specific window within a
> given tag. This is especially useful in tiling mode, because all the
> windows are visible, so it's much clearer which number to use to get
> to a certain window.
>
> Here's how to configure it:
>
> { MODKEY, XK_F1, focusnumber, {.i = 1 } },
> { MODKEY, XK_F2, focusnumber, {.i = 2 } },
> ...
>
> Thanks for developing such a slim, powerful window manager.
>
> Marshall
>
Received on Sun Nov 25 2012 - 20:02:54 CET

This archive was generated by hypermail 2.3.0 : Sun Nov 25 2012 - 20:12:04 CET