[hackers] [tabbed][PATCH] add _NET_WM_PID support

From: nrk=disroot.org <NRK>
Date: Wed, 11 Nov 2026 12:08:38 +0000

_NET_WM_PID allows for better scripting things. E.g:

        txid=$(tabbed -d)
        tpid=$(xprop -id "$txid" _NET_WM_PID | cut -d' ' -f 3)

grabs both the xid and pid of the tabbed window/process.
---
 tabbed.c | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/tabbed.c b/tabbed.c
index 145a637..d7907c1 100644
--- a/tabbed.c
+++ b/tabbed.c
_at_@ -49,7 +49,7 @@
 #define TEXTW(x)                (textnw(x, strlen(x)) + dc.font.height)
 
 enum { ColFG, ColBG, ColLast };       /* color */
-enum { WMProtocols, WMDelete, WMName, WMState, WMFullscreen,
+enum { WMProtocols, WMDelete, WMName, WMState, WMPid, WMFullscreen,
        XEmbed, WMSelectTab, WMLast }; /* default atoms */
 
 typedef union {
_at_@ -137,6 +137,7 @@ static void updatenumlockmask(void);
 static void updatetitle(int c);
 static int xerror(Display *dpy, XErrorEvent *ee);
 static void xsettitle(Window w, const char *str);
+static void xsetpid(void);
 
 /* variables */
 static int screen;
_at_@ -1049,6 +1050,7 @@ setup(void)
 	wmatom[WMFullscreen] = XInternAtom(dpy, "_NET_WM_STATE_FULLSCREEN",
 	                                   False);
 	wmatom[WMName] = XInternAtom(dpy, "_NET_WM_NAME", False);
+	wmatom[WMPid] = XInternAtom(dpy, "_NET_WM_PID", False);
 	wmatom[WMProtocols] = XInternAtom(dpy, "WM_PROTOCOLS", False);
 	wmatom[WMSelectTab] = XInternAtom(dpy, "_TABBED_SELECT_TAB", False);
 	wmatom[WMState] = XInternAtom(dpy, "_NET_WM_STATE", False);
_at_@ -1330,6 +1332,14 @@ xsettitle(Window w, const char *str)
 	}
 }
 
+void
+xsetpid(void)
+{
+	long pid = getpid();
+	XChangeProperty(dpy, win, wmatom[WMPid], XA_CARDINAL, 32,
+	                PropModeReplace, (unsigned char *)&pid, 1);
+}
+
 void
 usage(void)
 {
_at_@ -1433,6 +1443,7 @@ main(int argc, char *argv[])
 		}
 	}
 
+	xsetpid(); /* correct pid is the one after detaching */
 	run();
 	cleanup();
 	XCloseDisplay(dpy);
-- 
2.54.0
Received on Wed Nov 11 2026 - 13:08:38 CET

This archive was generated by hypermail 2.3.0 : Wed Nov 11 2026 - 13:12:45 CET