r/javascript • • Nov 03 '26

I built Domicile, a Linux desktop platform where native application windows are DOM elements

https://www.domicile-desktop.com/

I've been working on Domicile, an open-source platform for building full-featured Linux desktop environments using HTML, CSS, and JavaScript/TypeScript.

It's powered by a modified Chromium engine where native Wayland application windows are DOM elements. You can position, style, transform, and animate actual Linux application windows using CSS.

Desktop environments are JavaScript/TypeScript modules that can use familiar frameworks, be distributed through npm or GitHub, and be hot-swapped without restarting the session.

It ships with Manganese, a Sway-inspired tiling desktop built using the platform.

Source: https://github.com/cprussin/domicile

I'd love to hear what JavaScript developers think!

0 Upvotes

30 comments sorted by

4

u/JuniorWMG Nov 03 '26

Love how the Git readme already says "May God have mercy on our souls". May he indeed.

3

u/cprussin1 Nov 03 '26

I have low hopes that he will. Some sins are too great.

Forgive me father, for I have forked Chromium.

1

u/JcerParreno21 26d ago

at least the author is self aware about what theyve unleashed

1

u/gianluca_caruso-6 17d ago

For hot-swapped JS shells, does a reload recreate module state, or is state migrated across the module boundary?

1

u/cprussin1 17d ago

It's up to the shell to persist & restore state if it wants to do so, which can happen using localstorage. The engine stores internal state about which windows / webviews are open, what's focused, and other Wayland state, so that will persist across shells, but the placement etc is up to the shell to restore on startup.

I have a proof of concept of this with Manganese -- basically we just persist the layout tree to localstorage and restore on shell startup -- but I haven't deployed it in practice; I figure this is something I'll make easier if more people build shells and shell switching becomes more common. If this is something you care about, dm me and we can think about how to make it nicer on shell authors.

1

u/cprussin1 17d ago

Also note that it isn't actually "hot-swap" in the sense of e.g. vite / webpack HMR. In theory I think HMR would work as well (and would of course persist state like any other HMR setup), but I haven't tested it (although I'm going to add some tests to the test suite now to make sure it actually does work).

Instead, the shell swap behaves as a navigation with a fresh document just like if you navigated to a new site on a typical browser. There's a new document, a new js realm, etc.

1

u/gsamantha_831 13d ago

CSS transforms make native windows expressive; how are pointer hit-testing and coordinates mapped back to Wayland?

1

u/cprussin1 13d ago

So actually we don't do a whole lot, chromium does it for us. Each window is an `<app>` element backed by a real layer in Chromium's layer tree, so Blink hit-tests it like any other element. The engine maps the event into the element's local space with Blink's own layout math (same as offsetX), which inverts every ancestor transform, zoom and perspective. Then it scales to the client's buffer size, and the compositor sends a normal wl_pointer.motion via Smithay. Presses take pointer capture, like a Wayland implicit grab.

1

u/p-reyes-6823 10d ago

CSS transforms on native windows are a neat primitive; can a shell crash without taking the session down?

1

u/cprussin1 10d ago

Shell crashes are captured and recovered by the engine

1

u/dmart2782 6d ago

The JS shell ecosystem is compelling; what trust boundary applies to third-party modules that control the desktop?

1

u/cprussin1 5d ago

Shell modules are trusted code, like a program you run in Node. They run as your user and can read and write files, spawn processes and use D-Bus, so only install modules you trust. Websites you open get none of that. They stay in Chromium's normal sandbox, can't reach the shell's APIs, and their permission requests (camera, notifications and so on) go to the shell for you to answer.

1

u/s-torres-73 5d ago

Can shell modules be pinned or reviewed before updates? Running as your user makes package integrity part of desktop security.

1

u/cprussin1 5d ago

Yes. Shells never auto-update. Domicile installs a shell once, on first use, with install scripts disabled, and bun's lockfile pins the exact version, its integrity hash and, for GitHub specs, the commit. After that it only changes if you change the spec or clear its cache.

To pin exactly, use a version (`my-shell@1.2.3`), a commit (`github:me/repo#<sha>`), a local checkout you've reviewed, or a Nix derivation pinned by flake.lock. Domicile's own packages always come from the Domicile install itself, never npm.

What's missing today: a review step before updates, signature or provenance checks beyond npm's hash, and per-shell capability limits. These are all great ideas, so I'm adding them to the roadmap and will work on getting them shipped soon.

A shell runs with your user's full access, so pin and review it like any other code you run.

-1

u/olegispe Nov 03 '26

Apart from the insane impracticality and inefficiency of this, this is unironically cool

Type of thing I'd use if I had 32GB of graphics memory... but then Sam Altman would need it for his data centres

1

u/cprussin1 Nov 03 '26

Actually it's surprisingly efficient! I have a ton of perf measurements here that you can take a look at: https://github.com/cprussin/domicile/blob/main/docs/architecture/ENGINE-FORK-MEASUREMENTS.md

In terms of memory consumption, domicile only uses marginally more memory than what is used by Chromium itself when running it as an app inside of another compositor, and nearly all of the memory use is taken by the shell's JS process for shell state, not by domicile itself. In general with most perf stuff, domicile actually performs nearly as well if not better than just running chromium inside another compositor, from my measurements & anecdotal experience -- and this is certainly the goal & intention.

I'm actually daily driving Manganese ( https://www.domicile-desktop.com/manganese ) - the reference shell that I built with domicile - on a shitty integrated graphics chip on my CPU and driving 3 4k monitors with it. It actually is anecdotally smoother than using swaywm used to be!

1

u/Old_Shock_4609 Nov 04 '26

That's awesome. Running great in a 2G vm on a 2017 macBook.
Unfortunatly only Settings window shows up, if I try to open native apps it opens a transparent window althought I can see app icon and title in titlebar.

1

u/cprussin1 Nov 04 '26

Looking into it!

1

u/cprussin1 Nov 04 '26

Which VM app is it (VirtualBox, VMware, UTM, Parallels), and is 3D acceleration on? A quick workaround to try: start domicile with DOMICILE_SOFTWARE_COMPOSITING=yes set. If that doesn't fix it, could you post the output of journalctl --user -b | grep -i domicile and ls -l /sys/class/drm/*/device/driver?

1

u/Old_Shock_4609 Nov 04 '26

managed to get it running with software compositing on. And hw accel with:

DOMICILE_SOFTWARE_COMPOSITING=no
DOMICILE_ENGINE_ARGS="--ignore-gpu-blocklist --disable-gpu-sandbox"

(something about vmwgfx being blocked)

1

u/cprussin1 Nov 05 '26

Yep, it looks like Chromium blocks vmwgfx. I have a fix in the latest release (just cut) that enables fallback CPU rendering. I'm separately working on a fix that will enable vmwgfx access directly which should result in better perf, but the latest release should be enough to work at decreased perf. I'll have the proper fix in as soon as I'm able to get some time to get vmware set up and have a proper repro.

1

u/cprussin1 29d ago

FYI I just cut another release that includes the fixes here, you should get gpu-optimized rendering in vmware without needing any flags now. LMK if it works for you!

1

u/Old_Shock_4609 29d ago

Works great.
Impressive work, do you see it as a viable alternative as Clutter / Qt / whatever for writing a solid DE ? What about the Xwayland limitation ?

1

u/cprussin1 29d ago

To be entirely honest, I'm not sure.

When I started this, it was mostly an experiment in the idea that in many ways, the web browser is just another compositor / window manager running inside your existing compositor / window manager. So the original idea was "I think I could make cool things if I collapsed that stack" - i.e. treating websites as first-class windows, having direct desktop support for chrome plugins, having web-stack desktop apps without having to use Electron, etc.

I get everyone's objections, but it seems inescapable to me that you'll be running a shitload of Chromium instances (the browser, every electron app, etc) anyways, so I was curious if this could be cleaner by collapsing the stack here.

I'm pleasantly surprised in my own use. I've completely switched to Managnese for the last few weeks and I don't see myself going back ever. Its very easy to do cool things with my desktop, and I really have not noticed any serious downsides once I got things stable.

For sure there will be perf (and other) tradeoffs with this architecture, but like I said, I'm actually surprised at how well it works. As it turns out, Chormium is actually a VERY sophisticated compositor. Most of the perf tradeoffs anecdotally seem to be things you're already trading off by running the browser inside another compositor. And being able to treat websites like any other window has had some little awesome UX benefits.

Anyhow, glad to hear you think it's nifty, and please do let me know if you build anything / need more support on it!

1

u/cprussin1 29d ago

Oh, and regarding xwayland -- I don't personally use any xorg apps any more so I just never prioritized it, but you can run xwayland-satellite and it totally works: https://github.com/Supreeeme/xwayland-satellite

I think that's arguably less performant than direct xwayland support and I'll totally be open to adding direct xwayland support if people actually want it, I just don't need it personally so I never prioritized it.

1

u/Old_Shock_4609 Nov 04 '26 edited Nov 04 '26

It's a VMware with 3D on, GNOME running fine on it
starting domicile with software compositing on gives the same result
see log on https://pastebin.com/ivfzfPQ6

0

u/olegispe Nov 03 '26

Huh neat. Piqued my interest there 😂

1

u/[deleted] Nov 03 '26

[removed] — view removed comment

1

u/CodySkatez2005 Nov 03 '26

Does a director work on a film even though he/she doesn't man every camera?

0

u/r2d2_21 29d ago

A director directs a team of people, not a team of robots.