Tech News
← Back to articles

I finally got my sway layout to autostart the way I like it

read original related products more articles

I finally got my sway layout to autostart just the way I like it

I have been using sway as my default window manager on my laptop for a few years. One of the things that I’ve found most annoying about it, after over a decade of using KDE, was the lack of automated save and restore of running applications. There is a way to auto-start applications, but not to specify the way the resulting windows will be laid out.

Every time I went looking, I could only find partial, hacky, or unreliable solutions, often full of artificial delays to try to address race conditions. Suffice to say I was not satisfied with anything I found, so I accepted that I had to setup my starting configuration on every reboot.

Another round of experiments

Over the last couple of months, with tremendous help from Claude Code, I have been migrating my janky homelab, haphazardly hand-crafted over the course of ~7 years, to a more reproducible setup, standardizing on a single distro (Arch), and using Ansible to provision each machine.

As I was looking through a variety of config files on my main laptop, and deciding what to manage with ansible, I was once again reminded of my desire for a smoother and more automated session startup, so I decided to run a few experiments with Claude.

The results were honestly pretty bad.

Claude was running into the same race conditions that countless humans had to wrestle with before, and despite valiant efforts, none of its approaches were getting anywhere satisfying…

RTFM

I was too invested to just give up though, so I took a serious look at the sway manpages, and, right there, staring at me, I found the kernel of a solution: the event stream for created windows includes the pid of the process that spawns it!

... continue reading