I've made a little progress with this generation of a json layout spec. Note 
that I am trying to be completely json compliant. So, unlike the i3-save-tree 
(which saves multiple json documents), I have a json spec that only has one 
json document. My reading of the i3 documentation seems to suggest that i3 has 
no problem with this, and it seems that it doesn't have a problem.

In the sample that I provided below I have reduced the spec to the following 
form:

{"fullscreen_mode": 1, "floating": "auto_off", "border": "normal", "layout": 
"splith", "percent": null, "nodes": [{"window_properties": {"title": "yo"}, 
"fullscreen_mode": 0, "floating": "auto_off", "border": "normal", "layout": 
"splith", "percent": 0.5,  "nodes": [], "type": "con", "swallows": [{"class": 
"^XTerm$"}], "name": "ubuntu@example-8930: ~", "geometry": {"y": 0, "x": 0, 
"height": 316, "width": 484}}, {"window_properties": {"title": "go"}, 
"fullscreen_mode": 0, "floating": "auto_off", "border": "normal",  "layout": 
"splith", "percent": 0.5, "nodes": [], "type": "con", "swallows": [{"class": 
"^XTerm$"}], "name": "ubuntu@example-8930: ~", "geometry": {"y": 0, "x": 0, 
"height": 316, "width": 484}}], "type": "workspace", "swallows": []}

Notice that this spec actually has 3 swallows one for the parent workspace and 
two for the 2 xterm leaf nodes. Not sure why this is, but it is what I received 
when I requested the tree. I3-save-tree (I think) only shows a swallows for 
leaf nodes.

I can actually append this document to a workspace (i3-msg "workspace 2; 
append_layout /home/ubuntu/.i3/layout_spec") - i3 does not crash on this spec.

However I see two problems:
1] The spec actually overlays the workspace (rather than appending to it)
2] The windows do not swallow a subsequent xterm.

Why does this spec result in an "overlay" rather than an "append"?  Why is my 
swallow not working?

From: Sargrad, Dave
Sent: Monday, September 15, 2014 12:33 PM
To: 'i3-discuss@i3.zekjur.net'
Subject: i3 layout save/restore

I am trying to generate my own layout files in python (similar to the files 
generated by i3-save-tree). I am looking for something that describes the 
layout specification [above and beyond the i3-save-tree code, which is a bit 
cryptic for a non-perl expert].

I am already able to get the i3 tree in python. Furthermore I already have a 
number of operations that I perform on that tree. For example I have an 
operation that generates an image (representing the workspace structure) for 
each workspace in the tree. I am at a point where I need to generate layout 
specs, so that I can subsequently append these to workspaces.

The first couple of specs that I generated are essentially just a dump of the 
portion of the portion of the tree that corresponds to the workspace. I know 
these need to be tweaked further. For example I have not yet added "swallows", 
nor stripped non-necessary elements (like "fullscreen_mode" or "layout"). 
However I thought that i3 would allow me to load these specs and then I could 
begin to trim them and modify them until they looked more like the specs 
generated by i3-save-tree. Indeed I hoped that i3 might provide feedback 
relative to the elements of the spec that were not right.

The unfortunate thing is that i3 crashes when it attempts to load my specs. So 
rather than move from the form that I have incrementally towards the "right 
form", I need to jump to the right form more quickly.

A specification for the layout structure would help. Is there anything that 
exists above and beyond the perl code, and the samples of generated layouts 
that I can create with it?

For example, here is the portion of the tree that corresponds to the workspace 
that I am trying to save a spec for: this particular simple workspace is one 
window on top of another.  Other than the obvious things like adding a proper 
swallows element, what are the key things that I need to keep in mind when 
transforming portions of the i3 tree into a form that can later be appended?

{"fullscreen_mode": 1, "orientation": "horizontal", "focus": [23160000, 
23125184], "urgent": false, "num": 1, "last_split_layout": "splith", 
"floating": "auto_off", "border": "normal", "id": 23119648, 
"current_border_width": -1, "layout": "splith", "percent": null, 
"workspace_layout": "default", "window": null, "nodes": [{"window_properties": 
{"instance": "xterm", "class": "XTerm", "title": "ubuntu@example-8930: 
~/playground/cwpmash"}, "fullscreen_mode": 0, "orientation": "none", "focus": 
[], "urgent": false, "last_split_layout": "splith", "floating": "auto_off", 
"border": "normal", "id": 23125184, "current_border_width": -1, "layout": 
"splith", "percent": 0.5, "workspace_layout": "default", "window": 25165860, 
"nodes": [], "type": "con", "swallows": [], "focused": false, 
"scratchpad_state": "none", "rect": {"y": 18, "x": 0, "height": 1013, "width": 
840}, "window_rect": {"y": 0, "x": 2, "height": 1009, "width": 834}, "name": 
"ubuntu@example-8930: ~/playground/cwpmash", "geometry": {"y": 0, "x": 0, 
"height": 316, "width": 484}, "floating_nodes": []}, {"window_properties": 
{"instance": "xterm", "class": "XTerm", "title": "ubuntu@example-8930: ~"}, 
"fullscreen_mode": 0, "orientation": "none", "focus": [], "urgent": false, 
"last_split_layout": "splith", "floating": "auto_off", "border": "normal", 
"id": 23160000, "current_border_width": -1, "layout": "splith", "percent": 0.5, 
"workspace_layout": "default", "window": 27263012, "nodes": [], "type": "con", 
"swallows": [], "focused": true, "scratchpad_state": "none", "rect": {"y": 18, 
"x": 840, "height": 1013, "width": 840}, "window_rect": {"y": 0, "x": 2, 
"height": 1009, "width": 834}, "name": "ubuntu@example-8930: ~", "geometry": 
{"y": 0, "x": 0, "height": 316, "width": 484}, "floating_nodes": []}], "type": 
"workspace", "swallows": [], "focused": false, "scratchpad_state": "none", 
"rect": {"y": 0, "x": 0, "height": 1031, "width": 1680}, "window_rect": {"y": 
0, "x": 0, "height": 0, "width": 0}, "name": "1", "geometry": {"y": 0, "x": 0, 
"height": 0, "width": 0}, "floating_nodes": []}

The correct form (as generated by i3-save-tree) is:

// vim:ts=4:sw=4:et
{
    "border": "normal",
    "floating": "auto_off",
    "geometry": {
       "height": 316,
       "width": 484,
      "x": 0,
       "y": 0
    },
    "name": "ubuntu@example-8930: ~/playground/cwpmash",
    "percent": 0.5,
    "swallows": [
       {
       // "class": "^XTerm$",
       // "instance": "^xterm$",
       // "title": "^ubuntu\\@example\\-8930\\:\\ 
\\~\\/playground\\/cwpmash$<file:///\\~\playground\cwpmash$>"
       }
    ],
    "type": "con"
}

{
    "border": "normal",
    "floating": "auto_off",
    "geometry": {
       "height": 316,
       "width": 484,
       "x": 0,
       "y": 0
    },
    "name": "ubuntu@example-8930: ~",
    "percent": 0.5,
    "swallows": [
       {
       // "class": "^XTerm$",
       // "instance": "^xterm$",
       // "title": "^ubuntu\\@example\\-8930\\:\\ \\~$"
       }
    ],
    "type": "con"
}

http://i3wm.org/docs/layout-saving.html#_saving_the_layout



This message is intended only for the addressee and may contain information 
that is company confidential or privileged. Any technical data in this message 
may be exported only in accordance with the U.S. International Traffic in Arms 
Regulations (22 CFR Parts 120-130) or the Export Administration Regulations (15 
CFR Parts 730-774). Unauthorized use is strictly prohibited and may be 
unlawful. If you are not the intended recipient, or the person responsible for 
delivering to the intended recipient, you should not read, copy, disclose or 
otherwise use this message. If you have received this email in error, please 
delete it, and advise the sender immediately.

Reply via email to