[i3] Layout saving/restoring (PREVIEW)

  • From: Michael Stapelberg <michael@xxxxxxxx>
  • To: "i3 discussions" <i3-discuss@xxxxxxxxxxxxx>
  • Date: Sun, 15 Dec 2013 22:11:26 +0100

Hi,

I have been working on layout/session saving/restoring this
weekend. The title is a mouthful, but what it’s about is saving parts of
your layout (say, an entire workspace) to a JSON file and later loading
that into i3.

This is useful for multiple things:

1) Restoring a certain layout when starting up your x session.
People used to do this with shell scripts and hacks such as
i3-exec-wait until now.

2) Defining a more elaborate default layout for certain workspaces. As
an example, on my big screen I like to have three columns of stacked
containers with terminals in them, where the middle one is larger
than the left and right ones.

I uploaded a video to demonstrate how it looks:
http://youtu.be/CaDOfwxXc9g

To save a layout, there is i3-save-tree(1), which requires the Perl
modules AnyEvent::I3¹ and JSON::XS². i3-save-tree --workspace=1 prints
workspace 1’s layout to stdout. You are expected to edit that layout
file briefly, especially the “swallows” sections of each container. The
criteria should be familiar to you, e.g. from for_window.

Once you have done that, you can use the append_layout command to load a
layout file.

As for the code, I just pushed the branch “session-saving”, which you
can build and use right now. It’s stable enough that I’m using it on my
main machine. But, since this is a very new feature, be prepared to
encounter some stability issues (e.g. layout files that could crash
i3). You have been warned! :)

Also note that I reserve the right to break this feature in any way that
I deem necessary, and you have no right to complain about layout file or
new command breakage :).

As for the release plan: I intend to release i3 4.7 soonish (maybe in a
week or so). After that is done, I’ll merge the session-saving branch
into the “next” branch, i.e. the earliest i3 release that can possibly
have this feature will be 4.8.

http://michael.stapelberg.de/cpan/#AnyEvent::I3
http://michael.stapelberg.de/cpan/#JSON::XS

--
Best regards,
Michael

Other related posts:

  • » [i3] Layout saving/restoring (PREVIEW) - Michael Stapelberg