I'm writing a program in C++ (Linux,XWindow) that is supposed to modify an active window's title. More specifically, append certain text to it.
Is it possible to get a Window handle of an active window (even if it is not related to this program) to use it in XFetchName and XStoreName? Or, maybe there is some other way to modify a certain window's title?
Thank you.
update 1:
I used
xprop -root | grep ^_NET_ACTIVE_WINDOW | cut -c41-49
and it returns the correct handle. Thank you for this advice. This is what I used before
xdpyinfo | grep focus: | cut -c16-24
Looks like it returns a number that is greater than the actual handle by 1.
A new question arises now. It seems that XStoreName modifies WM_NAME. I have Unity desktop, and it seems that it reads _NET_WM_NAME instead. How can I modify this one as well?
update 2: found an answer
Atom Atom_name = XInternAtom(xdisplay,"_NET_WM_NAME",false);
Atom Atom_utf_type = XInternAtom(xdisplay,"UTF8_STRING",false);
XChangeProperty(xdisplay,window_handle,Atom_name,Atom_utf_type,8,PropModeReplace,(unsigned char*)new_name,strlen(new_name));
seems to work fine for now