parkouss / pyewmh

An implementation of EWMH (Extended Window Manager Hints) for python, based on Xlib.
GNU Lesser General Public License v3.0
40 stars 15 forks source link

Empty chromium and chrome get_wm_name. #15

Open unai-ndz opened 6 years ago

unai-ndz commented 6 years ago

If I run this:

from ewmh import EWMH

ewmh = EWMH()
windows = ewmh.getClientList()

for w in windows:
    # Window name (Title)
    print(w.get_wm_name())
    print(w.get_wm_class()[1])

I get:

Chromium

Google-chrome
Terminal
Xfce4-terminal
~/gits/test_ewmh/test.py (i3close) - Sublime Text
Sublime_text

While running: xprop | grep WM_NAME Outputs:

WM_NAME(UTF8_STRING) = "New Issue · parkouss/pyewmh - Chromium"
_NET_WM_NAME(UTF8_STRING) = "New Issue · parkouss/pyewmh - Chromium"

and

WM_NAME(UTF8_STRING) = "duckduckgo at DuckDuckGo - Google Chrome"
_NET_WM_NAME(UTF8_STRING) = "duckduckgo at DuckDuckGo - Google Chrome"

I have tested this on a new pypenv with ewmh-0.1.6, python-xlib-0.23, six-1.11.0 and Python 3.6.5 I can't test this on others environments or browsers right now, but maybe I'm doing something wrong. Did you have any idea or want more info?

creallfluharty commented 4 years ago

(Not involved in this project, just thought I'd comment) Though I can't speak to why get_wm_name() is empty (beyond the possibility that it may just be unset), if you didn't know already, in order to get _NET_WM_NAME (rather than _WM_NAME) you can use EWMH.getWmName, like:

from ewmh import EWMH

ewmh = EWMH()
windows = ewmh.getClientList()

for w in windows:
    # Window name (Title)
    print(ewmh.getWmName(w))
    print(w.get_wm_class()[1])

Just pure speculation, but I wonder if xprop would use _NET_WM_NAME as a fallback, given that - at least on my machine - WM_NAME is usually of type STRING, rather than UTF8_STRING

In any case, I believe the get_wm_name method is actually a method of python-xlib's Window (see here), so this problem may be entirely outside of pyewmh's control.

MestreLion commented 1 year ago

Indeed, Window.get_wm_name() is from python-xlib, and it reads the WM_NAME property. It is empty because of bug https://github.com/python-xlib/python-xlib/issues/212

To get the (preferred) _NET_WM_NAME property, use emwh.EWMH.getWmName(window) as @creallfluharty suggested