dwm-focusurgent-20221004-6.3.diff - sites - public wiki contents of suckless.org
 (HTM) git clone git://git.suckless.org/sites
 (DIR) Log
 (DIR) Files
 (DIR) Refs
       ---
       dwm-focusurgent-20221004-6.3.diff (2066B)
       ---
            1 Author: Jan Christoph Ebersbach <jceb@e-jc.de>
            2 URL: http://dwm.suckless.org/patches/focusurgent
            3 focusurgent selects the next window having the urgent flag regardless of the tag
            4 it is on.  The urgent flag can be artificially set with the following xdotool
            5 command on any window: xdotool selectwindow -- set_window --urgency 1
            6 ---
            7 Author: Zhen Xu <xuzhen165@gmail.com>
            8 Update: adapt to multiple monitors. The original patch was not aware of multiple
            9 monitors. I tested with two monitors but I don't have access to more monitors.
           10 
           11 Index: clean/dwm/config.def.h
           12 ===================================================================
           13 --- a/config.def.h
           14 +++ b/config.def.h
           15 @@ -60,6 +60,7 @@ static char dmenumon[2] = "0"; /* component of dmenucmd, manipulated in spawn()
           16  static const char *dmenucmd[] = { "dmenu_run", "-m", dmenumon, "-fn", dmenufont, "-nb", col_gray1, "-nf", col_gray3, "-sb", col_cyan, "-sf", col_gray4, NULL };
           17  static const char *termcmd[]  = { "st", NULL };
           18  
           19 +#include "focusurgent.c"
           20  static Key keys[] = {
           21          /* modifier                     key        function        argument */
           22          { MODKEY,                       XK_p,      spawn,          {.v = dmenucmd } },
           23 @@ -95,6 +96,7 @@ static Key keys[] = {
           24          TAGKEYS(                        XK_8,                      7)
           25          TAGKEYS(                        XK_9,                      8)
           26          { MODKEY|ShiftMask,             XK_q,      quit,           {0} },
           27 +        { MODKEY,                       XK_u,      focusurgent,    {0} },
           28  };
           29  
           30  /* button definitions */
           31 Index: clean/dwm/focusurgent.c
           32 ===================================================================
           33 --- /dev/null
           34 +++ b/focusurgent.c
           35 @@ -0,0 +1,20 @@
           36 +static void
           37 +focusurgent(const Arg *arg) {
           38 +        Monitor *m;
           39 +        Client *c;
           40 +        int i;
           41 +        for(m=mons; m; m=m->next){
           42 +                for(c=m->clients; c && !c->isurgent; c=c->next);
           43 +                if(c) {
           44 +                        unfocus(selmon->sel, 0);
           45 +                        selmon = m;
           46 +                        for(i=0; i < LENGTH(tags) && !((1 << i) & c->tags); i++);
           47 +                        if(i < LENGTH(tags)) {
           48 +                                const Arg a = {.ui = 1 << i};
           49 +                                view(&a);
           50 +                                focus(c);
           51 +                                warp(c);
           52 +                        }
           53 +                }
           54 +        }
           55 +}