Can you please stop creating new threads for this? This is the fourth
thread on the same topic that I have in my Inbox right now.

Also, it seems like your questions are better suited for a live medium
like IRC. Or just sleep over what you have and ask the next day, since
you seem to frequently figure it out after posting to the list.

On Tue, Sep 16, 2014 at 1:20 PM, Sargrad, Dave
<dave.sarg...@saabsensis.com> wrote:
> I almost have this working.
>
> Can someone please explain to me what the following code snippet (drawn from 
> i3-save-tree) does:
>
>
>     for my $key (qw(nodes floating_nodes)) {
>         $tree->{$key} = [ map { strip_containers($_) } @{$tree->{$key}} ];
>     }
>
> I think this is making a recursive call to strip_containers, for containers 
> that container either "nodes" or "floating_nodes".
It is replacing “nodes” and “floating_nodes” with the result of
calling strip_containers() on each of the elements of “nodes” and
“floating_nodes”.

>
> I don’t see the code that actually deletes "empty nodes" and empty 
> "floating_nodes". Perhaps this code does that as well through the creation of 
> a new map that contains just the allowed_keys..
http://code.stapelberg.de/git/i3/tree/i3-save-tree?id=ad7bf58822b7d6f937a6da29689b8177fd69cc05#n170

>
>
>
> -----Original Message-----
> From: i3-discuss [mailto:i3-discuss-boun...@i3.zekjur.net] On Behalf Of 
> i3-discuss-requ...@i3.zekjur.net
> Sent: Tuesday, September 16, 2014 6:01 AM
> To: i3-discuss@i3.zekjur.net
> Subject: i3-discuss Digest, Vol 53, Issue 6
>
> Send i3-discuss mailing list submissions to
>         i3-discuss@i3.zekjur.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://infra.in.zekjur.net/cgi-bin/mailman/listinfo/i3-discuss
> or, via email, send a message with subject or body 'help' to
>         i3-discuss-requ...@i3.zekjur.net
>
> You can reach the person managing the list at
>         i3-discuss-ow...@i3.zekjur.net
>
> When replying, please edit your Subject line so it is more specific than "Re: 
> Contents of i3-discuss digest..."
>
>
> Today's Topics:
>
>    1. Re: i3-discuss Digest, Vol 53, Issue 5 (Sargrad, Dave)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 15 Sep 2014 18:50:01 +0000
> From: "Sargrad, Dave" <dave.sarg...@saabsensis.com>
> To: "i3-discuss@i3.zekjur.net" <i3-discuss@i3.zekjur.net>
> Subject: Re: [i3] i3-discuss Digest, Vol 53, Issue 5
> Message-ID:
>         <85ea6f68ac24da48b220ebea7a8c08b81b506...@corpmail01.corp.sensis.com>
> Content-Type: text/plain; charset="utf-8"
>
> Ok. I have made even further headway with this. Let me summarize what I think 
> I have learned:
>
> 1] By removing the window_properties from the spec I was able to get the 
> "swallows" to work properly 2] By only including the leaf nodes I was able to 
> append, rather than overlay.
>
> So it would seem that i3 has the ability to not only append a layout but to 
> overlay a layout (onto an existing workspace). This almost seems like a 
> feature. Though I am not sure what unintended consequences there might be.
>
> The latter can be seen in two examples:
> The following spec does an append:
>
> {
>         "window_properties": {"title": "mo"},
>         "fullscreen_mode": 0,
>         "floating": "auto_off",
>         "border": "normal",
>         "layout": "splith",
>         "percent": 0.5,
>         "nodes": [],
>         "type": "con",
>         "swallows": [
>                     {
>                     "class": "^XTerm$"
>                     }
>         ],
>         "name": "one",
>         "geometry": {"y": 0, "x": 0, "height": 316, "width": 484} }
>
> {
>         "fullscreen_mode": 0,
>         "floating": "auto_off",
>         "border": "normal",
>         "layout": "splith",
>         "percent": 0.5,
>         "nodes": [],
>         "type": "con",
>         "swallows": [
>                 {
>                 "class": "^XTerm$"
>                 }
>         ],
>         "name": "two",
>         "geometry": {"y": 0, "x": 0, "height": 316, "width": 484} }
>
> Whereas by keeping the parent workspace we end up with an overlay:
>
> {
> "fullscreen_mode": 1,
> "floating": "auto_off",
>  "border": "normal",
> "layout": "splith",
> "percent": null,
>  "nodes": [
>           {
>          "fullscreen_mode": 0,
>          "floating": "auto_off",
>          "border": "normal",
>          "layout": "splith",
>          "percent": 0.5,
>          "nodes": [],
>          "type": "con",
>          "swallows": [{"class": "^XTerm$"}],
>          "name": "one",
>          "geometry": {"y": 0, "x": 0, "height": 316, "width": 484}},
>          {
>          "fullscreen_mode": 0,
>          "floating": "auto_off",
>          "border": "normal",
>          "layout": "splith",
>          "percent": 0.5,
>          "nodes": [],
>          "type": "con",
>          "swallows": [{"class": "^XTerm$"}],
>          "name": "two",
>          "geometry": {"y": 0, "x": 0, "height": 316, "width": 484}}
>          ],
> "type": "workspace",
> "swallows": []
> }
>
> -----Original Message-----
> From: i3-discuss [mailto:i3-discuss-boun...@i3.zekjur.net] On Behalf Of 
> i3-discuss-requ...@i3.zekjur.net
> Sent: Monday, September 15, 2014 1:41 PM
> To: i3-discuss@i3.zekjur.net
> Subject: i3-discuss Digest, Vol 53, Issue 5
>
> Send i3-discuss mailing list submissions to
>         i3-discuss@i3.zekjur.net
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         http://infra.in.zekjur.net/cgi-bin/mailman/listinfo/i3-discuss
> or, via email, send a message with subject or body 'help' to
>         i3-discuss-requ...@i3.zekjur.net
>
> You can reach the person managing the list at
>         i3-discuss-ow...@i3.zekjur.net
>
> When replying, please edit your Subject line so it is more specific than "Re: 
> Contents of i3-discuss digest..."
>
>
> Today's Topics:
>
>    1. i3 layout save/restore (Sargrad, Dave)
>    2. Re: i3 layout save/restore (Sargrad, Dave)
>
>
> ----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 15 Sep 2014 16:33:04 +0000
> From: "Sargrad, Dave" <dave.sarg...@saabsensis.com>
> To: "i3-discuss@i3.zekjur.net" <i3-discuss@i3.zekjur.net>
> Subject: [i3] i3 layout save/restore
> Message-ID:
>         <85ea6f68ac24da48b220ebea7a8c08b81b506...@corpmail01.corp.sensis.com>
> Content-Type: text/plain; charset="utf-8"
>
> 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$"
>        }
>     ],
>     "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.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://infra.in.zekjur.net/pipermail/i3-discuss/attachments/20140915/5655f113/attachment-0001.html>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 15 Sep 2014 17:38:45 +0000
> From: "Sargrad, Dave" <dave.sarg...@saabsensis.com>
> To: "i3-discuss@i3.zekjur.net" <i3-discuss@i3.zekjur.net>
> Subject: Re: [i3] i3 layout save/restore
> Message-ID:
>         <85ea6f68ac24da48b220ebea7a8c08b81b506...@corpmail01.corp.sensis.com>
> Content-Type: text/plain; charset="utf-8"
>
> 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.
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: 
> <http://infra.in.zekjur.net/pipermail/i3-discuss/attachments/20140915/4450c667/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> i3-discuss mailing list
> i3-discuss@i3.zekjur.net
> http://infra.in.zekjur.net/cgi-bin/mailman/listinfo/i3-discuss
>
>
> ------------------------------
>
> End of i3-discuss Digest, Vol 53, Issue 5
> *****************************************
> -
> 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.
> -
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> i3-discuss mailing list
> i3-discuss@i3.zekjur.net
> http://infra.in.zekjur.net/cgi-bin/mailman/listinfo/i3-discuss
>
>
> ------------------------------
>
> End of i3-discuss Digest, Vol 53, Issue 6
> *****************************************
> -
> 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.
> -



-- 
Best regards,
Michael

Reply via email to