tabbed

tab interface for application supporting Xembed
git clone git://git.suckless.org/tabbed
Log | Files | Refs | README | LICENSE

commit 4eba47b048a22f4166836c6c2e233f9712930ec5
parent e65146d2918e0072fc09b3dfb06785e170787164
Author: NRK <nrk@disroot.org>
Date:   Wed, 11 Nov 2026 12:08:38 +0000

add _NET_WM_PID support

_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.

Diffstat:
Mtabbed.c | 13++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/tabbed.c b/tabbed.c @@ -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 { @@ -135,6 +135,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; @@ -1010,6 +1011,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); @@ -1284,6 +1286,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) { die("usage: %s [-dfksv] [-g geometry] [-n name] [-p [s+/-]pos]\n" @@ -1386,6 +1396,7 @@ main(int argc, char *argv[]) } } + xsetpid(); /* correct pid is the one after detaching */ run(); cleanup(); XCloseDisplay(dpy);