altdesktop / i3ipc-python

🐍 An improved Python library to control i3wm and sway.
http://i3ipc-python.readthedocs.io
BSD 3-Clause "New" or "Revised" License
851 stars 109 forks source link

no con.to_string() #145

Closed jpmorris closed 4 years ago

jpmorris commented 4 years ago

My high level goal: I want to hide windows on my laptop 'presentation mode' and pull them all back 'personal mode'

I couldn't find a way to do this strictly with i3-msg, so I turned to this library. I see get_tree which gives me everything I need, but if I want to save state I want to dump this to a file somewhere. However the only way I can do this is by invoking a shell command (os.shell('i3-msg..')) this seems clunky. Is there no way to just dump all window states to json?

acrisci commented 4 years ago

I'm planning to save all the raw json from the ipc for the objects.

If you just want the raw json of the tree, there's no public api for that, but it's there internally. I might consider exposing that if there is a use case but nobody has ever asked for it.

jpmorris commented 4 years ago

ok thanks. My use case is above, but probably not a common one. As a workaround I'm just running the i3-msg in the shell to dump the tree so i can save my state of my windows.

ammgws commented 4 years ago

Is this solved by 8947b9f048ce87712b6ce8fea9aef7af4b100b27?

acrisci commented 4 years ago

You could satisfy this use case with that because the ipc_data member is serializable.