JonnyHaystack / i3-resurrect

Simple solution to saving and restoring i3 workspaces
GNU General Public License v3.0
379 stars 19 forks source link

Some windows not restored #60

Closed sabrehagen closed 4 years ago

sabrehagen commented 4 years ago

I use multiple instances of VS Code across my workspaces. When restoring, my first VS Code will be restored, but other VS Code instances appear like this:

image

What causes this? Given that multiple VS Code windows can be opened, how come they are not restored successfully? Other applications such as Chrome open just fine across multiple workspaces.

Sorry for my lack of understanding of the inner workings of your tool. Thanks for your work!

JonnyHaystack commented 4 years ago

I might have to try using VS Code to see how it works. Can you send me contents of the programs.json files?

sabrehagen commented 4 years ago

Sure thing. I'm using i3-workspace-names-daemon which stores filenames as unicode characters, but I haven't found this to be an issue when using python3 as the interpreter.

image

https://gist.github.com/sabrehagen/08f6e0dfb58d5010aef039a02529f121 https://gist.github.com/sabrehagen/51f791bf3c5ed46cb8db966549e68775 https://gist.github.com/sabrehagen/7ea70bc507929ee08d79cb2ff4f03254 https://gist.github.com/sabrehagen/62811aa8b7e54bba4e3a56ff19a016f7

These are my save and restore scripts:

Save Restore

JonnyHaystack commented 4 years ago

Yes, unicode characters should be handled fine.

In your programs files I can see that you are opening the same file in both instances. When you run the command to open the same file, it just focuses the existing window. In fact even if you run the command to open another file, it will open it in the existing window in a new tab.

This is a behaviour of VS Code which I cannot change, however VS Code does have a command line flag to force opening in a new window:

  -n --new-window                   Force to open a new window.

If you use this flag to open the files, they should restore in separate windows.

EDIT: I realise this may not be entirely satisfactory if you don't usually launch VS Code from a shell. I am currently thinking of ways to improve the custom command mappings such that you can interpolate parts of the process's actual cmdline into your custom command. It should be pretty easy using python's str.format(), so you could put something in your config like:

{
  "window_command_mappings": [
    {
      "class": "Code",
      "command": "code -n {1}"
    }
  ]
}

I will probably do it like this for the next release, but I'm open to other suggestions.

Also thanks for the sponsorship! Only just saw that :smile:

sabrehagen commented 4 years ago

Exceptional diagnosis - thank you! That method of command mapping works for me. You're welcome re the sponsorship, glad I can help out :)

That issue is resolved. Rather than making a new issue I want to ask one other question. You'll notice I have a step to clear urgency on windows after launch. If I don't do this, all workspaces are marked urgent until I switch to them. Do you experience this too? How do you get around it?

JonnyHaystack commented 4 years ago

I guess it's because you're restoring all the workspaces at once. I don't do that because I manually apply the layouts after programs are restored. i3-resurrect does not have any information on programs after they are launched and it doesn't know when they are done launching, so your way of handling it seems like the most appropriate way to do it.