This sets _NET_WM_PID on startup.  Not sure if any error handling's needed.  I
used this for quite a while before I switched back to urxvt (for scrollback)
for the same purpose as the recent "in $PWD" thread.

---
 st.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/st.c b/st.c
index 50b58a7..e3a7719 100644
--- a/st.c
+++ b/st.c
@@ -399,6 +399,7 @@ static int xsetcolorname(int, const char *);
 static int xloadfont(Font *, FcPattern *);
 static void xloadfonts(char *, int);
 static int xloadfontset(Font *);
+static void xsetnetwmpid(void);
 static void xsettitle(char *);
 static void xresettitle(void);
 static void xsetpointermotion(int);
@@ -3028,6 +3029,7 @@ xinit(void) {
        xresettitle();
        XMapWindow(xw.dpy, xw.win);
        xhints();
+       xsetnetwmpid();
        XSync(xw.dpy, 0);
 }
 
@@ -3347,6 +3349,13 @@ xdrawcursor(void) {
        }
 }
 
+void
+xsetnetwmpid(void) {
+       Atom _NET_WM_PID = XInternAtom(xw.dpy, "_NET_WM_PID", False);
+       pid_t pid = getpid();
+       XChangeProperty(xw.dpy, xw.win, _NET_WM_PID, XA_CARDINAL, 32,
+                       PropModeReplace, (unsigned char *)&pid, 1);
+}
 
 void
 xsettitle(char *p) {
-- 
1.8.4.1


Reply via email to