←back to thread

1080 points mmulet | 3 comments | | HN request time: 0s | source

I made a built-from scratch Wayland Compositor to display any GUI app* in the terminal! I think there is a lot of unexplored potential in custom Wayland compositors, a lot of really cool things you can embed existing applications into! So, I started with embedding apps into the terminal because that is the easiest input/output (output is just utf-8 and I use the great `chafa` library for that, and I just read from stdin for the input).

If you have any other ideas for cool Wayland compositors, let me know. I purposedly wrote 80% the app in Typescript to appeal to the most developers and attract cool contributions (I do all drawing with the familiar Canvas2D api, so if there is interest, I can also fork this out into a cool Terminal canvas, let me know!)

I have a blog post here about how I did it, but it’s pretty high level and non technical, so please ask if you have any questions.

[How I Did It](<https://github.com/mmulet/term.everything/blob/main/resource...>)

*technically only Wayland apps and x11 apps with Xwayland. But on Linux that’s mostly everything.

Show context
alkh ◴[] No.45199274[source]
This is so cool, thanks for sharing! Having this on a Mac would be great but I understand that this might be a huge undertaking :)
replies(1): >>45199476 #
mmulet ◴[] No.45199476[source]
I definitely want to make a macOS version, but I haven’t even looked into it yet. So, I don’t know the level of hacking required. It definitely doesn’t sound like anything Apple would have an api for, so it would probably be a vnc or accessibility api trick.
replies(1): >>45199958 #
krackers ◴[] No.45199958[source]
I think there is an API (that was added with sidecar) to create a virtual display. So at best you could retrieve the framebuffer and then display that. I don't think there is an easy exposed way to get per-window information, aside from doing a screencapture (which likely would not work if you also wanted to hide the window).
replies(1): >>45200373 #
1. mmulet ◴[] No.45200373[source]
Interesting… do you have a link to the docs? The easiest thing prob would be to set the window to be fullscreen, but on that virtual display. That would accomplish per window screen capture.
replies(1): >>45201767 #
2. krackers ◴[] No.45201767[source]
It's a private API CGVirtualDisplay, but mostly well reverse engineered. Here's one example I found of a wrapper library

https://github.com/enfp-dev-studio/node-mac-virtual-display/...

replies(1): >>45202391 #
3. mmulet ◴[] No.45202391[source]
100. Thanks!