[dev] [dwm] NetActiveWindow

From: Peter John Hartman <peterjohnhartman_AT_gmail.com>
Date: Tue, 12 Apr 2011 11:08:20 -0400

Hi. Thanks go also to LokiChaos on #suckless. With this little patch[1] you
can now use this little script[2] (and others presumably) to manipulate windows
via xdotool in dwm. The little script conjurs up a list of available windows
(via xprop and xdotool), pipes it into dmenu, which then passes it off to an
xdotool windowactivate. I find this useful when I have oodles of zathuras open.
But the general usefulness of getting _NET_ACTIVE_WINDOW implemented is, well,
obvious.

[1]

diff -r 072c62ed10f2 dwm.c
--- a/dwm.c Fri Jan 07 16:05:22 2011 +0000
+++ b/dwm.c Tue Apr 12 11:03:54 2011 -0400
@@ -58,7 +58,7 @@
 enum { CurNormal, CurResize, CurMove, CurLast }; /* cursor */
 enum { ColBorder, ColFG, ColBG, ColLast }; /* color */
 enum { NetSupported, NetWMName, NetWMState,
- NetWMFullscreen, NetLast }; /* EWMH atoms */
+ NetWMFullscreen, NetActiveWindow, NetLast }; /* EWMH atoms */
 enum { WMProtocols, WMDelete, WMState, WMLast }; /* default atoms */
 enum { ClkTagBar, ClkLtSymbol, ClkStatusText, ClkWinTitle,
        ClkClientWin, ClkRootWin, ClkLast }; /* clicks */
@@ -1310,6 +1310,10 @@
                         arrange(c->mon);
                 }
         }
+ if(c && cme->message_type == netatom[NetActiveWindow]) {
+ focus(c);
+ restack(selmon);
+ }
 }
 
 void
@@ -1517,6 +1521,7 @@
         wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
         wmatom[WMDelete] = XInternAtom(dpy, "WM_DELETE_WINDOW", False);
         wmatom[WMState] = XInternAtom(dpy, "WM_STATE", False);
+ netatom[NetActiveWindow] = XInternAtom(dpy, "_NET_ACTIVE_WINDOW", False);
         netatom[NetSupported] = XInternAtom(dpy, "_NET_SUPPORTED", False);
         netatom[NetWMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
         netatom[NetWMState] = XInternAtom(dpy, "_NET_WM_STATE", False);

[2]

#!/bin/sh

foo=$(for i in $(xdotool search --onlyvisible ".*"); do
        win_id="${i}"
        win_class=$(xprop -id ${win_id} WM_CLASS | cut -d'"' -f2)
    win_title=$(xprop -id ${win_id} _NET_WM_NAME | cut -d'"' -f2)
        echo "${win_title}|${win_class}|${win_id}"
done | dmenu -l 5 | cut -d'|' -f3)
xdotool windowactivate ${foo}

-- 
sic dicit magister P
PhD Candidate
Collaborative Programme in Ancient and Medieval Philosophy
University of Toronto
http://individual.utoronto.ca/peterjh
Received on Tue Apr 12 2011 - 17:08:20 CEST

This archive was generated by hypermail 2.2.0 : Tue Apr 12 2011 - 17:12:02 CEST