Readit News logoReadit News
Posted by u/mmulet 3 months ago
Show HN: Term.everything – Run any GUI app in the terminalgithub.com/mmulet/term.ev...
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.

nick__m · 3 months ago
That's awesomely useless, it straddles the line between programming and art.

I am sure it was a great and fun learning experience.

Well done !

GTP · 3 months ago
Well, not 100% useless: I can see its use for applications running inside Docker containers. Yes, there are ways to have GUI applications rendered from the inside of a container, but maybe this is easier than getting the Dockerfile right.

EDIT: nevermind, doing this with Docker seems much easier than I expected [0]. I'll try it tomorrow, I'm curious to see if the proposed solution works on Windows as well.

[0] https://medium.com/@priyamsanodiya340/running-gui-applicatio...

nicce · 3 months ago
Windows had Wayland support before most distros! Rather surprising.
actsasbuffoon · 3 months ago
Yeah, I can’t explain why this project makes me so happy because I struggle to think of any time where I’d need this, but it puts a big, dumb grin on my face.
snozolli · 3 months ago
It reminds me a bit of chindōgu, the Japanese art (?) of useless inventions. There's a particular delight to ingenious, but absurd or useless creations.
pawelduda · 3 months ago
Well, you can run apps on any less capable device with ssh and proper terminal display. You can limit data usage by offloading video buffering to the host (however not sure if that's net positive saving). And put the host behind VPN to avoid getting region blocks.
msdz · 3 months ago
It's like a more generalized browsh[1].

[1] https://www.brow.sh/

mmulet · 3 months ago
<3
dmayle · 3 months ago
Definitely not useless!

I run a ttyd server to get terminal over https, and I have used carbonyl over that to get work done. That's limited to a web browser (to get access to resources not exposed via the public internet), so having full GUI support is very useful

reactordev · 3 months ago
This is one of those things that pushes the boundaries to nowhere, yet everywhere at the same time whilst being incredibly awesome and something you can show off ad infinitum. Outstanding! Not sure how we’ll implement vdi now! Gives ghost in the shell a whole new meaning.

But can it run doom?

mmulet · 3 months ago
Ask and ye shall receive: Running doom: https://github.com/mmulet/term.everything/blob/main/resource...

I had the change a couple of line to make it work because term.everything takes input only from stdin (this way it works of ssh and is pretty broadly compatible across terminals).

1. I had to remap another key to the control key (which is usually used to send signals like sigterm)

2. Then I had to change the timeout in which keys are pressed. When using stdin, you get a keydown event, but you don't get a key up event (ever). So I have to guess when you want to key up. Most of the time, I can send key up right away. But, it looks like doom has some sort of key debounce, so I had to wait 50-100 ms for keyup. Then there is the problem of if you want to walk forward in games you usually hold down up arrow, but now you have to rapidly press it! Not ideal, but it does work, and it it playable.

reactordev · 3 months ago
Phenomenal!!!

I used to write telnet games so I know all about keypress up never coming through. Even with immediate mode (so repeated keys will send repeated key codes while held down) it never tells you when it stops. You have to read the buffer ascii byte by byte. Still, awesome to see. Great work!!!

anthk · 3 months ago
aaquake ran under ASCII terminals before this ever existed.
reactordev · 3 months ago
But that isn’t this, answered above.
shonku · 3 months ago
Absolutely love the energy here. You really terminally outdid yourself here. Consider me officially shell-shocked.
pbhjpbhj · 3 months ago
Terrible puns. But at least you gave it a bash.
psd1 · 3 months ago
Very prompt. This thread has Bourne fruit. I'm uTTYerly impressed.
tri2820 · 3 months ago
This is such a cool project. Personally, I think there are so many interesting use cases that can be built on top of Wayland, like https://github.com/udevbe/greenfield and this
marcodiego · 3 months ago
This is interesting, but there was something that was even more impressive many years ago: a GTK theme that rendered all decoration and widgets using text chars and a GDK backend that rendered to text. Combine both and you could run any GTK app on a terminal with legible text and a beautiful TUI.

http://zemljanka.sourceforge.net/cursed/screenshots/

pndy · 3 months ago
Damn I have a vague memories of seeing this thing in Fedora Core
colecut · 3 months ago
why did this go away?
saghm · 3 months ago
Maybe linking to this reminded the owner that they had a sourceforge account they had forgotten about, and they took the opportunity to delete it.
warwren · 3 months ago
I remember the carbonyl project to run chromium in the terminal that got me really excited (https://github.com/fathyb/carbonyl) but it eventually became unmaintained.

This is pretty much that but supercharged. Definitely really cool to see. Good work!

serbuvlad · 3 months ago
We got Wayland over vt100 escape codes over ssh over tcp before we got a headless Wayland VNC/RDP solution.
wdavidw · 3 months ago
A few years back, I was deploying, operating and debugging a Hadoop cluster with Kerberos enabled behind a firewall with only the SSH port being opened. Without a web browser would have been a much more complicated task. I ended up installing the X11 client on my local macOS and the all Gnome + Firefox on one of the cluster's node. Something that is not doable with Wayland. This project work like a charm, here is a quick example on how to test it inside an Incus container (I had to install 2 additional dependencies).

  # Work with Gnome terminal but resolution is much better in something supporting images
  apt install -y kitty
  kitty
  # Create an incus container
  incus --project default launch images:ubuntu/24.04 term
  incus --project default shell term
  # Install dependencies
  apt install -y curl firefox libharfbuzz0b libfontconfig1
  curl -L -o term https://github.com/mmulet/term.everything/releases/download/0.5.1/term.everything.mmulet.com-dont_forget_to_chmod_+x_this_file
  mv term.everything.mmulet.com-dont_forget_to_chmod_+x_this_file term
  chmod u+x term
  echo '<h1>Hello</h1>' > test.html
  # Start firefox, wait for a few seconds
  ./term firefox test.html