You are not logged in.

#1 2017-07-31 15:33:50

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 298

[Solved] i3 restore layout not working

After setting up my workspace with the containers that I want, I saved the layout:

i3-save-tree --workspace 1 > ~/.config/i3/workspace-1.json

I edited the file, uncommented the lines "class":

"class": "^Atom$",
"class": "^Google\\-chrome\\-beta$",
"class": "^Xfce4\\-terminal$",

I realize this isn't very useful, but I just wanted to test to see how/if it worked.

I added the following line to my config file:

exec --no-startup-id "i3-msg 'workspace 1; append_layout /home/username/.config/i3/workspace-1.json'"

However, i3 logs the following:

07/31/2017 05:21:41 PM - ERROR: JSON parsing error: parse error: invalid object key (must be a string)
             "class": "^Atom$",        }     ],     "type": "con" }  {
                     (right here) ------^

ERROR: Your command: (null)
ERROR:               (null)
ERROR: parse error: invalid object key (must be a string)
             "class": "^Atom$",        }     ],     "type": "con" }  {
                     (right here) ------^

[{"success":false,"error":"parse error: invalid object key (must be a string)\n             \"class\": \"^Atom$\",        }     ],     \"type\": \"con\" }  {\n                     (right here) ------^\n"}]

I have no idea what's wrong there, I just removed the "//" to uncomment the lines. Here's the full JSON file:

{
    "border": "normal",
    "current_border_width": 2,
    "floating": "auto_off",
    "geometry": {
       "height": 1400,
       "width": 1143,
       "x": 2,
       "y": 38
    },
    "name": "untitled — Atom",
    "percent": 0.288333333333333,
    "swallows": [
       {
       "class": "^Atom$",
       }
    ],
    "type": "con"
}

{
    "border": "normal",
    "current_border_width": 2,
    "floating": "auto_off",
    "geometry": {
       "height": 1400,
       "width": 2009,
       "x": 2,
       "y": 38
    },
    "name": "i3: Layout saving in i3 - Google Chrome",
    "percent": 0.423333333333333,
    "swallows": [
       {
       "class": "^Google\\-chrome\\-beta$",
       }
    ],
    "type": "con"
}

{
    "border": "normal",
    "floating": "auto_off",
    "layout": "splitv",
    "percent": 0.288333333333333,
    "type": "con",
    "nodes": [
        {
            "border": "normal",
            "current_border_width": 2,
            "floating": "auto_off",
            "geometry": {
               "height": 722,
               "width": 850,
               "x": 0,
               "y": 0
            },
            "name": "Terminal - ingemar@atlantis:~/.config/i3",
            "percent": 0.5,
            "swallows": [
               {
               "class": "^Xfce4\\-terminal$",
               }
            ],
            "type": "con"
        },
        {
            "border": "normal",
            "current_border_width": 2,
            "floating": "auto_off",
            "geometry": {
               "height": 722,
               "width": 850,
               "x": 0,
               "y": 0
            },
            "name": "Terminal - ingemar@atlantis:~",
            "percent": 0.5,
            "swallows": [
               {
               "class": "^Xfce4\\-terminal$",
               }
            ],
            "type": "con"
        }
    ]
}

Why is i3 throwing me those errors? Any ideas what I need to change to make this work?

Thanks!

Last edited by mouseman (2017-07-31 18:28:58)

Offline

#2 2017-07-31 15:51:15

rtoijala
Member
Registered: 2011-09-11
Posts: 36

Re: [Solved] i3 restore layout not working

Without having tested it, I suspect the problem is the trailing comma, which is not allowed by the JSON spec.
You could try removing it.

Offline

#3 2017-07-31 18:06:50

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 298

Re: [Solved] i3 restore layout not working

rtoijala wrote:

Without having tested it, I suspect the problem is the trailing comma, which is not allowed by the JSON spec.
You could try removing it.

Cool, good one!

I only removed the ones on the classes line and it's now restoring the layout. The original i3 save had comments that I removed in an attempt to fix the issue. When I uncomment any of those, should I remove the trailing comma as well, or should all trailing comma's throughout that file be removed?

Here's the original file:

// vim:ts=4:sw=4:et
{
    "border": "normal",
    "current_border_width": 2,
    "floating": "auto_off",
    "geometry": {
       "height": 1400,
       "width": 1143,
       "x": 2,
       "y": 38
    },
    "name": "untitled — Atom",
    "percent": 0.288333333333333,
    "swallows": [
       {
       // "title": "^untitled\\ \\—\\ Atom$",
       // "transient_for": "^$"
       }
    ],
    "type": "con"
}

{
    "border": "normal",
    "current_border_width": 2,
    "floating": "auto_off",
    "geometry": {
       "height": 1400,
       "width": 2009,
       "x": 2,
       "y": 38
    },
    "name": "Post a reply / Arch Linux Forums - Google Chrome",
    "percent": 0.423333333333333,
    "swallows": [
       {
       // "class": "^Google\\-chrome\\-beta$",
       // "instance": "^google\\-chrome\\-beta\\ \\(\\/home\\/ingemar\\/\\.config\\/google\\-chrome\\-beta\\)$",
       // "title": "^Post\\ a\\ reply\\ \\/\\ Arch\\ Linux\\ Forums\\ \\-\\ Google\\ Chrome$",
       // "transient_for": "^$",
       // "window_role": "^browser$"
       }
    ],
    "type": "con"
}

{
    // splitv split container with 2 children
    "border": "normal",
    "floating": "auto_off",
    "layout": "splitv",
    "percent": 0.288333333333333,
    "type": "con",
    "nodes": [
        {
            "border": "normal",
            "current_border_width": 2,
            "floating": "auto_off",
            "geometry": {
               "height": 722,
               "width": 850,
               "x": 0,
               "y": 0
            },
            "name": "Terminal - ingemar@atlantis:~/.config/i3",
            "percent": 0.5,
            "swallows": [
               {
               // "class": "^Xfce4\\-terminal$",
               // "instance": "^xfce4\\-terminal$",
               // "title": "^Terminal\\ \\-\\ ingemar\\@atlantis\\:\\~\\/\\.config\\/i3$",
               // "transient_for": "^$",
               // "window_role": "^xfce4\\-terminal\\-1501524280\\-720054400$"
               }
            ],
            "type": "con"
        },
        {
            "border": "normal",
            "current_border_width": 2,
            "floating": "auto_off",
            "geometry": {
               "height": 722,
               "width": 850,
               "x": 0,
               "y": 0
            },
            "name": "Terminal - ingemar@atlantis:~",
            "percent": 0.5,
            "swallows": [
               {
               // "title": "^Terminal\\ \\-\\ ingemar\\@atlantis\\:\\~$",
               // "transient_for": "^$"
               }
            ],
            "type": "con"
        }
    ]
}

Thanks again!

Offline

#4 2017-07-31 18:28:40

mouseman
Member
From: Outta nowhere
Registered: 2014-04-04
Posts: 298

Re: [Solved] i3 restore layout not working

Nevermind, I found my answer here:
https://bbs.archlinux.org/viewtopic.php?id=225142

The comma needs to be removed from the last line in every "swallows" sections.

Thanks!

Offline

Board footer

Powered by FluxBB