Forking Chrome to render in a terminal
fathy.fr
fathy.fr
http://github.com/csdvrx/sixel-tmux
For example with Windows Terminal: https://raw.githubusercontent.com/csdvrx/sixel-tmux/main/exa...
OP, if you want to keep your current solution, check how going beyond unicode halfblocks can help: https://github.com/csdvrx/derasterize
In a way, using sixel-tmux is like "giving magical goggles" to your terminal, to let it render sixels so you can see something (even if it isn't perfect), in the hope you'll be tempted to use a better terminal that will show you sixels in all their glory, with a pixel perfect quality.
Sixels enable all kind of cool things, like gnuplot right in your terminal (cf https://github.com/csdvrx/sixel-gnuplot ): sometimes I even watch youtube on my terminal lol
sixel-tmux was made as a first step towards turning derasterize into a more general library: my plan was to add it to nnn but I got bored along the way and moved to other stuff. I might still do that I I love nnn as a filemanager.
BTW, even if there have been quite a few interesting work by @hpa and others in the last 2 years, I think derasterize still has textmode supremacy. derasterize is a collab with @jart after I started adding features to her previous solutions which was based on half blocks like this solution; she's also made further work based on this like https://justine.lol/printimage.html and https://justine.lol/printvideo.html
On Linux, virtual terminals are currently limited to 512 glyphs and 16 colors. You can't do much graphics with that, unless you bypass the terminal layer and write directly to the framebuffer, like w3mimg does.
On the font issue, yes, sadly you are right. It's retarded to just have 512 glyphs on a framebuffer, not a true tty. The framebuffer or KMS should support TTF fonts by default. A Unifont TTF would be godsend here.
I only had a vague memory it was huge, expensive and got very warm but in the 1980s there weren't any graphics like it, most high tech for the time.
*Issue is Chrome doesn't support extensions in headless mode.
`xvfb-run --server-args="-screen 0 1920x1080x24" google-chrome --remote-debugging-port=9222 --disable-gpu http://example.org`
This project, on the other hand, allows me to "watch" Youtube videos across a fairly slow SSH connection on a remote host on the other side of NA, and "smoothly" scroll around, looking through comments and the like.
Comparing them side by side, it seems like brow.sh is a bit more precise (re: layout), but carbonyl is much more responsive. Very impressive. Not sure if there's a use for watching Unicode youtube videos in the terminal, but impressive!
This seems like an automation dream for all kinds of things when I want to see browser interactions and results - but all from a terminal! This is awesome.
Even better: https://en.wikipedia.org/wiki/Sixel Doesn't support 24-bit color though.
I’m still exploring it thought, but as a separate program to run any X apps through SSH.
Read https://sw.kovidgoyal.net/kitty/graphics-protocol/
Then read about the sixel format, and decide which one you think is the easiest to support.
The Kitty protocol starts with multiple formats:
>> The terminal emulator must understand pixel data in three formats, 24-bit RGB, 32-bit RGBA and PNG.
Different tools for different needs, but if you are going for a wide support you want something simple that doesn't also have 5 different types you have to separately implement and test:
>> d: Direct (the data is transmitted within the escape code itself)
>> f: A simple file (regular files only, not named pipes or similar)
>> t: A temporary file, the terminal emulator will delete the file after reading the pixel data. For security reasons the terminal emulator should only delete the file if it is in a known temporary directory, such as /tmp, /dev/shm, TMPDIR env var if present and any platform specific temporary directories and the file has the string tty-graphics-protocol in its full file path.
>> s: A shared memory object, which on POSIX systems is a POSIX shared memory object and on Windows is a Named shared memory object. The terminal emulator must read the data from the memory object and then unlink and close it on POSIX and just close it on Windows.
> What nonsense, it takes literally 15 lines of code without using anything beyond the standard library to write a client
Conveniently taking a preencoded PNG and assuming away the necessary queries of supported protocol:
>> Since a client has no a-priori knowledge of whether it shares a filesystem/shared memory with the terminal emulator, it can send an id with the control data, using the i key (which can be an arbitrary positive integer up to 4294967295, it must not be zero).
> I challenge you to match that for sixel
Challenge accepted. There are many libraries for many languages. Let's look at this one in perl:
https://github.com/saitoha/libsixel/tree/master/perl
use Image::LibSIXEL;
$encoder = Image::LibSIXEL::Encoder->new();
$encoder->setopt("w", 400);
$encoder->setopt("p", 16);
$encoder->encode("images/egret.jpg");
and some print($encoder) to print the output, and this works on all the terminals listed on https://www.arewesixelyet.com/Compared to kitty: "As of April 2022, kitty and WezTerm are the only terminal emulators to support this graphics protocol completely, with Konsole and wayst having partial support"
There are many nice things about the kitty protocol, but I think it's ultimately too complicated for the task. It's a Homer Mobile: https://www.wired.com/2014/07/homer-simpson-car/
If we want graphics in the terminal, first we need graphics in the terminal (using sixels is the simplest way, and you get access to many tools) then you can do more if you still want to - but you're likely to realize by then that all the extra things Kitty supports is YAGNI: https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it?use...
Funny, I don't see vt52, vt100, vt102, vt200, xterm et al. on that list. Could this be why sixels aren't everywhere except terminal emulators that run on gui platforms with highly advanced graphics already?
1) sixel has no querying. So if you want to compare apples to apples, you leave out the querying from the kitty protocol as well.
2) The code I linked to above uses only the standard library which I emphasized. You are using some random sizel specific library to add support for sixel to your perl script.
So no, you dont meet the challenge. I can output images with the kitty protocol using pure BASH + base64, available everywhere.
Oh and incidentally the saitoha sixel library is both unmaintained and full of security issues, so save yourself some headaches and dump it. Trying to claim the kitty protocol is harder to use than sixel is beyond disingenuous.
Either you have PNG data, or you have to support the various RGB encodings
> I can output images with the kitty protocol using pure BASH + base64, available everywhere.
This is disingenuous: so can I if instead of .PNG files, I have .SIX files.
I won't even need base64 - which you'll need to write in shell script if you write a portable bash script. And if want you want to show isn't .png or .jpg, you'll need more...
> Trying to claim the kitty protocol is harder to use than sixel is beyond disingenuous.
Funny, because I think the same about you.
Given the tone of your previous post, and the tone of this post, I'm out.
Good that you are out, hopefully you are out of trying to shill sixels as well.
I suggest a hard look in the mirror or at your post history to see the kitty fanboyism tuned to 11 (file format, keyboard shortcuts, etc)
Try mintty (from msys2), xterm or mlterm (multiplatform)
https://github.com/chrhasse/alacritty-sixel
It is crazyfast. Alacritty will merge it someday, but they have very very high standards and allowing graphics is a major change. So it's taking a lot of time.https://github.com/blitzcode/term-gfx/blob/master/src/main.r...
You're still just getting two colors per character, but I think it works quite nicely.
I really don't want to see this to fall behind upstream in terms of performance and security fixes.
From the author's Github repo:
# Watch YouTube inside a Docker container
$ docker run -ti fathyb/carbonyl https://youtube.com
Have you had problems with this triggering bot/scraper/abuse-detection?
You force-enable `kContentCapture`, `kContentCaptureTriggeringForExperiment`, and `kContentCaptureInWebLayer`, which make the browser look -- to the website -- a LOT like a bot/scraper and not at all like a normal user.
Something that could be cool is work with them/submit patches to improve the DevTools protocol to be more efficient and suited for Carbonyl and html2svg's use-case. Combined with a virtual X server (in Rust of course!), this could provide very similar performance and remove the need to fork.
For the bot-detection, I only had Twitter telling me the browser is not compatible so far, it was caused by the "Carbonyl (version)" user-agent. I fixed it by switching to "Chromium (version) / Carbonyl".
Good point on kContentCapture, I didn't realize it could be visible to websites. I enabled it to experiment with new ways to get text data, but ended falling back on Skia. I'm going to disable it now that it's unused!
The fork here goes even further, which is really cool.
The fork here goes incomparably further. Libcaca just produces an ‘ASCII art’ approximation of an image, not capable of handling text. So, while the photo is too small to see it, the text on the terminal is gibberish. The libcaca backend was done as an backend interoperability exercise, and run on a real terminal just for fun.
docker run -ti fathyb/carbonyl https://vscode.dev/ docker run -ti fathyb/carbonyl https://github1s.com/fathyb/carbonylBut it is close enough that with some work it could.
This is truly very impressive.
This is actually the showstopper for me with any kind of terminal browser. I enjoyed playing with browsh (or what was it called?) a few years ago, but this is much better.
I wonder if my suggested workaround has any meat to it.
"Forking Chrome to turn HTML into SVG" https://news.ycombinator.com/item?id=33584941 (471 points | 75 days ago | 97 comments)
It'd be fun to build a pure CLI-based OS around this. Imagine opening apps by running `/www/github.com`
> The inline images such as the world/book icon and the CERN icon, would have been displayed in separate windows, as it didn't at first do inline images.
Historically, DPS is one of the reasons Safari PDF exports look so good: Apple based CoreGraphics APIs on DPS to make the migration from NeXTStep to Mac OS easy. This makes the CoreGraphics<->PS/PDF conversion fairly straightforward.
[0]: https://www.w3.org/People/Berners-Lee/WorldWideWeb.html
[1]: https://developer.apple.com/documentation/appkit/nstext
There are some escape sequences you can feed to some terminals, though, that emit graphics. "Sixels" are pretty well known for pushing graphics to a terminal, but they're not universally supported.
iTerm2, on macOS, has a means of escaping and then sending a PNG, which is then displayed, IIRC. (But it's unique to iTerm2, and IIRC iTerm2 identifies as an xterm so it's basically impossible to autodetect.)
Start your xterm with the right flags and it will.
If you want a premade configuration, see https://github.com/csdvrx/CuteXterm
kitty + w3m is getting there as well.
But seriously, why not using browsers like lynx and links?
Am I missing something?
Just a consequence of turning a markup language into an OS.
Edbrowse uses it and it has enough JS support to even login and comment against JS ridden sites.
Browser, email, irc, SQL client, file manager and editor for the blind with an ed philosophy.
TFA doesn't seem to refer to electron at all. What's the connection here?
I good start: re-use the parsers from netsurf, get mr Bellard and friends quickJS... and then the ez part: get 748392749324732984 full-time devs full for 748937489234 centuries in order to get such engine working... BUT it is not finish since, once "working", you will have to play catch up with blackrock/vanguard financed web engines and everything they will do to break compat with your engine.
Some ppl are still trying with rust? servo something?
Thatcher is by design and I guess Google is mainly to blame by now.
Oh, and those ppl own and steer microsoft too, and some wonder why those are using blink now. I do ask myself how long they will keep webkit and blink since they have already geeko to feint the anti-trust laws.
But your are right, they made the "Standard" so insanely complex on top of the core noscript/basic (x)html, that it "works" only in their implementations with their armies of devs.
This is accutely toxic for humanity. The only "real" ways out of this: restore noscript/basic (x)html where it is still doing a good enough job, and if a "new" web has to be born: an implemention must be something reasonable in time/skills and efforts for a small team of devs.
And it "works"... never a very long time. It feels like once I manage to use edbrowse to interact with a "web app", it gets broken not that long after.
I think edbrowse should use the (x)html parser from netsurf.
2 examples:
- I did download my motherboard bios update with edbrowse... did that 1 time, then the site was changed and the new file download javascript code does not run with edbrowse and has not ever since.
- I used edbrowse to unlock the wifi in the starbucks in my city, 1 month later the javascript was changed and broke it. (I don't care anymore, I am going thru 4G, IPv6, anywhere I want now).
Their code is plain and simple C, namely their libs (because they did things cleanly), can be used as a stepping stone to write your own noscript browser, and if you want with CSS rendering.
Regarding the javascript-ed web, if you have 7483947398 devs for 479837438 centuries, and are able to sustain the permanent planned obsolescence and breakage of the web "standard", that for forever, you may have a chance to provide a real alternative implementation, namely not dependent on their SDK, so using a language simple enough like plain and simple C and certainly not c++/java and similar. Some are trying (still?) with rust (orders of magnitude cheaper than c++).
Don't forget, blink/geeko/webkit are financed by the blackrock/vanguard galaxy of owned companies ("big tech"), we are talking tens of thousands of billions of $, namely you must be "outside" the economy to have a chance, and don't worry, if you start to have something interesting (and that without using their SDK), they'll make your life rough (they will break their web sites/javascript on your implementation actively, "buy" your devs, try to torpedo your financing, etc).