orcsome icon indicating copy to clipboard operation
orcsome copied to clipboard

help(wm) doesn't show anything.

Open stuaxo opened this issue 10 years ago • 13 comments

I was wondering how to use this to get a window settings for a window belonging to some pid, but found that doing

from orcsome import get_wm
wm = get_wm()
help(wm)

doesn't have any info in it.

stuaxo avatar Oct 25 '15 11:10 stuaxo

I've commited into master ImmediateWM which allows to play with wm from repl.

>>> import orcsome.wm
>>> wm = orcsome.wm.ImmediateWM()
>>> help(wm)
>>> help(orcsome.wm.Window)
>>> print [(w.name, w.cls, w.title) for w in wm.get_clients()]
[('panel', 'bmpanel', None), ('urxvt', 'URxvt', 'terminal'), ('Navigator', 'Firefox', '\xc2\xabimmediate\xc2\xbb \xd0\xb2 \xd0\xbf\xd0\xb5\xd1\x80\xd0\xb5\xd0\xb2\xd0\xbe\xd0\xb4\xd0\xbd\xd1\x8b\xd1\x85 \xd1\x81\xd0\xbb\xd0\xbe\xd0\xb2\xd0\xb0\xd1\x80\xd1\x8f\xd1\x85 - Mozilla Firefox'), ('vial', 'URxvt', 'boo.http (~/work/dsfs) - VIM'), ('urxvt', 'URxvt', 'terminal'), ('urxvt', 'URxvt', 'terminal'), ('zathura', 'Zathura', 'weil-crush-sc06.pdf [4/12]'), ('urxvt', 'URxvt', 'terminal'), ('urxvt', 'URxvt', 'terminal'), ('vial', 'URxvt', 'wm.py (~/work/orcsome/orcsome) - VIM'), ('urxvt', 'URxvt', 'terminal'), ('vial', 'URxvt', '__init__.py (~/zvooq/zvq-prod/zvooq/utils) - VIM'), ('mutt', 'URxvt', 'mutt-minibav-1000-26901-17702220781800088554 + (/tmp) - VIM')]

There are no too many facilities to use orcsome like wmctrl. But you are welcome if you have some ideas in mind.

baverman avatar Oct 25 '15 11:10 baverman

Oops - just realised it was returning None. This is because I'm running in a virtualenv, and so couldn't use python-xlib. :/

stuaxo avatar Oct 25 '15 12:10 stuaxo

There is no need in python-xlib in latest master. The only requirement is cffi.

baverman avatar Oct 25 '15 13:10 baverman

$ ipython
In [1]: import orcsome
In [2]: orcsome.get_wm() == None
True

That's weird - should this work under gnome shell ?

stuaxo avatar Oct 25 '15 13:10 stuaxo

get_wm in repl always returns None. There is event loop so you must use ImmediateWM

baverman avatar Oct 25 '15 13:10 baverman

Note - I needed to sudo apt-get install libev-dev to import orcsome.wm

stuaxo avatar Oct 25 '15 13:10 stuaxo

Now, I have this working .. does it seems plausible to replace my dodgy use of xlsclients and xprop with orcsome here

https://gist.github.com/stuaxo/3942b4d077bb629acd2a << code, not necessarily worth looking at :)

I get the window info of a process I launch - with the idea that when I relaunch I will re-apply those same properties (x, y, width, height, z-index and attributes like 'always on top' to the new window ?

I'm guessing I could use "find_client" to do the initial "find the window belonging to the pid" part ?

stuaxo avatar Oct 25 '15 13:10 stuaxo

I'm guessing I could use "find_client" to do the initial "find the window belonging to the pid" part ?

Yep. You can iter through wm.get_clients and match pid with w.get_property('_NET_WM_PID')[0]

baverman avatar Oct 25 '15 14:10 baverman

Cool, I'll give that a go, is there a property for z-index of a window ?

stuaxo avatar Oct 25 '15 14:10 stuaxo

I will re-apply those same properties (x, y, width, height, z-index and attributes like 'always on top' to the new window ?

Usually it's responsibility of a WM to remember and restore client props. Orcsome have no dedicated methods/properties. There is only raw Window.get_property and WM._send_event.

baverman avatar Oct 25 '15 14:10 baverman

Ah, ok - I saw there is place_window_above and place_window_below. I'm doing a small reloader, so when code changes I reload the running app, + put will put it in the same place... if it's not possible to set z, I might just raise it to the top.

stuaxo avatar Oct 25 '15 14:10 stuaxo

Hm, you're right the location does seem to be the same - maybe I'm making work for myself :)

stuaxo avatar Oct 25 '15 14:10 stuaxo

if it's not possible to set z, I might just raise it to the top.

There is no a "z-index" notion in XWindow. Clients are organized in stack and can be moved or be pined to the top or to the bottom of it. place_window_* are move client.

baverman avatar Oct 25 '15 14:10 baverman