Mercurial > code > home > repos > racc
annotate collector/current_window_title_linux.py @ 8:af6e0049e701
deploy for vite
author | drewp@bigasterisk.com |
---|---|
date | Mon, 13 Mar 2023 18:54:47 -0700 |
parents | 5ad799e534a5 |
children | 6b6b1ea0e00d |
rev | line source |
---|---|
3 | 1 import Xlib |
2 import Xlib.display | |
3 | |
4 _disp = None | |
5 | |
6 | |
7 def get_current_window_title(): | |
8 global _disp | |
9 if _disp is None: | |
10 _disp = Xlib.display.Display() | |
11 window = _disp.get_input_focus().focus | |
12 # get_wm_name returns '': https://github.com/python-xlib/python-xlib/issues/212 | |
13 return window.get_property(_disp.get_atom("WM_NAME"), _disp.get_atom("UTF8_STRING"), 0, 1024).value.decode('utf8') |