You are not logged in.

#1 2013-05-05 08:17:42

graph
Member
Registered: 2010-12-21
Posts: 105

[DWM] How to get window titles (w/xprop?)

I'm trying to expand my "switch-to-tag"-script to include window titles, but have stumbled upon something I can't understand:

If I issue "xprop" (with no arguments), and click on my firefox-window, I get the following output:

user@host $ xprop (click on firefox window)
_NET_WM_USER_TIME(CARDINAL) = 6193278
WM_STATE(WM_STATE):
                window state: Normal
                icon window: 0x0
WM_HINTS(WM_HINTS):
                Client accepts input or input focus: True
                Initial state is Normal State.
                bitmap id # to use for icon: 0x14000aa
                bitmap id # of mask for icon: 0x14000ab
                window id # of group leader: 0x1400001
WM_WINDOW_ROLE(STRING) = "browser"
XdndAware(ATOM) = BITMAP
_MOTIF_DRAG_RECEIVER_INFO(_MOTIF_DRAG_RECEIVER_INFO) = 0x6c, 0x0, 0x5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x10, 0x0, 0x0, 0x0

 [[ !! HUGE ASCII ICON WAS DELETED TO SAVE SPACE HERE !! ]]

_NET_WM_SYNC_REQUEST_COUNTER(CARDINAL) = 20971689
_NET_WM_WINDOW_TYPE(ATOM) = _NET_WM_WINDOW_TYPE_NORMAL
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x14000a8
WM_CLIENT_LEADER(WINDOW): window id # 0x1400001
_NET_WM_PID(CARDINAL) = 873
WM_LOCALE_NAME(STRING) = "C"
WM_CLIENT_MACHINE(STRING) = "allotria"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified minimum size: 1 by 63
                program specified maximum size: 32767 by 32767
                window gravity: NorthWest
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING, _NET_WM_SYNC_REQUEST
WM_CLASS(STRING) = "Navigator", "Firefox"
WM_ICON_NAME(STRING) = "How do I get the active window title into a script? (Page 1) / Applications & Desktop Environments / Arch Linux Forums - Mozilla Firefox (Private Browsing)"
_NET_WM_ICON_NAME(UTF8_STRING) = "How do I get the active window title into a script? (Page 1) / Applications & Desktop Environments / Arch Linux Forums - Mozilla Firefox (Private Browsing)"
WM_NAME(STRING) = "How do I get the active window title into a script? (Page 1) / Applications & Desktop Environments / Arch Linux Forums - Mozilla Firefox (Private Browsing)"
_NET_WM_NAME(UTF8_STRING) = "How do I get the active window title into a script? (Page 1) / Applications & Desktop Environments / Arch Linux Forums - Mozilla Firefox (Private Browsing)"

So that worked alright. However, if I feed the ID of the window (0x1400001) to xprop, I get the following:

user@host $ xprop -id 0x1400001
WM_CLASS(STRING) = "firefox", "Firefox"
WM_COMMAND(STRING) = { "firefox" }
_NET_WM_USER_TIME_WINDOW(WINDOW): window id # 0x1400002
WM_CLIENT_LEADER(WINDOW): window id # 0x1400001
_NET_WM_PID(CARDINAL) = 873
WM_LOCALE_NAME(STRING) = "C"
WM_CLIENT_MACHINE(STRING) = "allotria"
WM_NORMAL_HINTS(WM_SIZE_HINTS):
                program specified size: 10 by 10
WM_PROTOCOLS(ATOM): protocols  WM_DELETE_WINDOW, WM_TAKE_FOCUS, _NET_WM_PING
WM_ICON_NAME(STRING) = "firefox"
_NET_WM_ICON_NAME(UTF8_STRING) = "firefox"
WM_NAME(STRING) = "Firefox"
_NET_WM_NAME(UTF8_STRING) = "Firefox"

There's no title in that output, even though I saw it by clicking - How come? And how do I grab the correct window title from a window id?

Last edited by graph (2013-05-05 08:18:10)

Offline

#2 2013-05-05 09:01:17

Unia
Member
From: Stockholm, Sweden
Registered: 2010-03-30
Posts: 2,486
Website

Re: [DWM] How to get window titles (w/xprop?)

Isn't it there in your first xprop output?

WM_NAME(STRING) = "How do I get the active window title into a script? (Page 1) / Applications & Desktop Environments / Arch Linux Forums - Mozilla Firefox (Private Browsing)"
_NET_WM_NAME(UTF8_STRING) = "How do I get the active window title into a script? (Page 1) / Applications & Desktop Environments / Arch Linux Forums - Mozilla Firefox (Private Browsing)"

If you can't sit by a cozy fire with your code in hand enjoying its simplicity and clarity, it needs more work. --Carlos Torres

Offline

#3 2013-05-05 09:02:34

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: [DWM] How to get window titles (w/xprop?)

man xprop wrote:

If the desired window is not the root window, it may be selected in two ways on the command line, either by id  number such as might be obtained from xwininfo, or by name if the window possesses a name.

The id you obtained from xprop is the WM_CLIENT_LEADER, also listed in the WM_HINTS as the group leader. So that appears to be something like a root window for Firefox, not necessarily the one you see (with the title you want).

Offline

#4 2013-05-05 09:28:43

graph
Member
Registered: 2010-12-21
Posts: 105

Re: [DWM] How to get window titles (w/xprop?)

#2: Yep, that's the one. However, I obtained that by clicking on the firefox window. I would like to get the window titles from all windows on the server without clicking on all windows.

#3: Hmm. I would like to use the list I get from xlsclients to get the WM_NAME for all windows. Having a script where I need to click on all windows for it to work, doesn't seem that efficient smile

Thanks for your input though, both of you.

Offline

Board footer

Powered by FluxBB