How does one autostart apps in specific workspaces with sway?

Cinnamon → Gnome → KDE → Sway … long journey, this feels pretty good though!

I’m used to having about 8 workspaces with specific apps on specific workspaces pre-opened. Plus browser windows (vivaldi and firefox) also open on specific workspaces. How do I do this with Sway? More specifically:

  • how can I start a bunch of single-window apps like signal, keepassxc, slack, dino in a tabbed container on a specific workspace?
  • how can I make it such that when vivaldi and firefox are started they open all the “saved session” windows in the workspaces that they used to be in? (This somehow worked both in cinnamon and kde)
  • I have two monitors, how can I ensure that the various workspaces are assigned to the correct monitor?

I feel like there must be a tutorial on how to do this type of stuff out there that I haven’t found yet… Maybe I need to look in the i3 world?

Pointers appreciated, thanks!!!

I used devilspie2 to get those affects on Cinnamon… how did you do it?

with KDE, of course it’s done using Window Rues, at least that’s how I do it.

Unless Sway has configuration options like KDE has, I’d suggest looking at devilspie2.

As far as Firefox is concerned it does save previous Session, but getting multiple windows to open in specific workspaces would require something like devilspie2, and probably autostart entries and or additional scripts.

Perhaps not… Wayland breaks devilspie2

Devilspie2 seems to be just one possible part of the solution. I still don’t quite understand how to generate the appropriate actions. Also, sway has all that matching built-in, so I’m not even sure that tool (or a wayland version) is necessary?

I’ve been looking at i3: Layout saving in i3 and that seems to another part of the solution, but I would hope there are tools wrapped around that low-level functionality…

WRT multi-window browsers, on Cinnamon and KDE when I launch vivaldi all the windows open on the same virtual desktops that they were on. Firefox on KDE was a bit more inconsistent with some windows going to the right places and some not.

On cinnamon I used devilspie2 lua scripts to differentiate which Firefox windows opened where. In addition I was, and still do, use Firefox Profiles, so not only separate Windows, but separate instances of Firefox for each Window, that made it easier to script for.

On KDE I can use the Window and Application Rules to open separate instances of Firefox on different workspaces.

I am also using devilspie2 to hide/unhide the panel when I am using a Virtual Machine, that way I can, with the help of Window Rules, make the VM window act AS IF it is in Full Screen mode.

I don’t know if any of that helps. But after doing some reading about Wayland, I am pretty sure devilspie2 won’t work for you.

I don’t know of anything like DP2 for Wayland.

It may be that some python scripts will help you achieve you goal. Unfortunately I don’t know enough about Wayland to be of any help in that respect, at the moment. In any case that seems like writing some sort of Wayland version of dp2.

i3 has a very good documentation. I guess sway has too.

As a follow-up: it’s a bloody mess…
i3 has functionality to dump the current layout and to restore it or fragments of it. Sway only has dump, no restore.
So to automatically configure a layout with apps one has to write scripts that use a combination of swaymsg, launching apps, and sway-toolwait to launch and place apps. A real PITA. See for example How to set layout of a container on startup? · Issue #5070 · swaywm/sway · GitHub