Graphical web browsing from the terminal
Tutorial – Carbonyl Graphical Web Browser
This Chromium port can run inside any console, with minimal resources, and is a great tool for making old computers really useful – and learning programming along the way.
Carbonyl [1] is a fork of the 100-percent open source version of Chrome called Chromium [2], which has a unique mission: turning any Linux terminal into a modern graphical web browser. In this tutorial, I describe how Carbonyl works, how to use it on Linux, and above all, why I consider this project interesting for programmers – and much more interesting for ordinary web users.
Features and Limitations
Let me acknowledge right away that, as cool as the concept is, Carbonyl has a few serious limitations – if you compare it to "ordinary" 100-percent graphical browsers, that is, and expect Carbonyl to replace them completely. The first obvious limit is that, while Carbonyl does handle images and video streaming, it does it at a much lower resolution than any browser running on top of a full-fledged, window-based interface.
Figure 1 is a good visual introduction to both the power and the limits of Carbonyl because it shows how the text browser w3m (left) and Carbonyl (right) render a page of the Linux Magazine website.
Yes, the actual images are quite grainy and pixelated, no question about that. But overall, there's no doubt that Carbonyl renders the web page much better, and much closer to what you would see in Firefox, Chrome, or Safari, than its text-only competitor w3m does in the left side of the figure. The fact that Carbonyl, while running in a Linux terminal, is much closer to "real" graphical browsers than to text-based ones is even more evident in Figure 2.
What you see in Figure 2 is the YouTube homepage loaded, left to right, inside w3m, Carbonyl, and good old Firefox (w3m and Carbonyl are running in two panes of the tmux terminal multiplexer [3]). YouTube is both recognizable and usable in the two rightmost windows, but no in the first one.
Running in the terminal, however, does not necessarily mean that all images will always be impossible to recognize, or that all video clips will be always impossible to follow. As proof of this statement, I offer Figure 3, which is a comedy skit on Italian moms that I was able to follow on YouTube with Carbonyl.
The left side of Figure 3 also shows the downside of what is by far the easiest "hack" you can use to make video inside Carbonyl viewable (at least for the moment): If you reduce the font size of the terminal that contains Carbonyl so much that text becomes really unreadable, video will be intelligible. Luckily, much better solutions are in the works (more on this below).
The second big limit of Carbonyl, which may be a showstopper for some users and a nonissue for others, is lack of support for Chrome/Chromium extensions. The third, which again may be an issue only if Carbonyl had to be your only browser, is the lack of bookmarks. However, because the developers' explicit goal is to integrate the complete Chromium user interface, both bookmarks and extensions should eventually be available in Carbonyl.
If you ask me, however, Carbonyl already more than makes up for these hopefully temporary limits with an excellent, probably unparalleled compromise between "weight" and performance, especially if you count useful performance. This browser supports all the modern web standards that matter for the overwhelming majority of users of graphic browsers, from JavaScript to WebGL, WebGPU, and audio and video playback (at 60 frames per second) and does so without carrying along the big ballast that is graphic servers such as X.Org or Wayland.
On my desktop, with 8GB of RAM, Carbonyl starts and displays complex web pages that look just like they would in Firefox, except for the quality of images, in a couple of seconds. Even better, it consumes almost no CPU cycles when it is idle. I could not test this personally, but its developers claim Carbonyl is usable even remotely over SSH, on platforms as lean as a Raspberry Pi.
The Case for Programmers
The first reason why every programmer may want to play with Carbonyl is obviously the same as the great mountaineer George Mallory had for climbing Everest: "Because it's there!" Or, as one of the first users of Carbonyl puts it [4], "if a full browser can be supported from the command line, what else is possible?"
A more pragmatic reason to participate in the development of this unusual browser may be career building. Carbonyl seems like an excellent playground for learning lots of technologies and algorithms whose existence and relevance are unknown to many millions of people who depend on them every day (see the "Carbonyl Technologies" box).
Carbonyl Technologies
Carbonyl is written in languages such as TypeScript, C++, and Rust, which would not look bad on any curriculum these days. The basis runtime used for rendering inside a terminal is the html2svg
utility [5], which was originally developed to convert HTML pages, including graphics generated on the fly in Canvas elements, to vector or bitmap images.
Carbonyl also uses, or plans to use, separate software rendering for text and images in the same window, including really obscure stuff (for me, at least) such as "quadrant binarization," which is a technique to render four visible pixels per terminal cell. At a higher level, playing with Carbonyl source code could be a good way to learn how to use and develop the Chromium profiles for Profile Guided Optimization (PGO) [6].
Last but not least, Carbonyl may teach many tricks about how to remove the cruft that plagues so many other FOSS packages. The first versions of Carbonyl had, just like ordinary Chromium, about 20 complex dependencies to deal with. The version current at the time of writing (Carbonyl 0.0.3) only has four. Not bad, is it?
The Case for End-Users
I consider Carbonyl a great way, if not the best-possible solution, to deal with a certain serious issue that plagues many "ultra-light" Linux distributions made to bring old hardware back to life and keep it out of the landfills.
Sure, thanks to those projects, you can install and run Linux on computers where no other operating system, including most current Linux distributions, could ever boot, or even fit in the first place. But then what?
As cool and efficient as those tiny Linuxes are, any computer running them would be practically useless for most newbies and expert Linux users, for one simple reason: These days, most of the things one needs to do with a computer can only happen online, inside a heavyweight graphical browser with lots of bells and whistles turned on.
In other words, certain distributions may be lighter than a feather, but without a browser that can really handle certain websites without bringing old hardware to its knees, very few people would find them useful. But this, as I hope I've already started to prove, is exactly the gap that Carbonyl may fill big time.
The reason is obvious: Normal GUI-based browsers cannot run without a windowing system underneath – something that may make low-end processors with little RAM choke, before you even try to start any GUI program. At the opposite corner of the browser market, text-based applications such as Lynx or w3m are great, but let's be realistic: Even if their lack of support for media playback didn't matter, they just cannot cope with modern, interactive websites.
For example, I cannot use w3m, Lynx, or anything like that to make online payments through my bank's website. Very likely, this is the bank's fault, not the browsers', but that doesn't make any practical difference: Either I use a GUI browser, or I must visit the closest physical branch to pay my bills.
With Carbonyl many of these problems disappear, and even more will do the same, if Carbonyl maintains its promises. Sure, images and videos look awful inside Carbonyl, but does it really always matter? To answer, please look at Figures 4, 5, and 6. The first contains the homepage of the English-language Wikipedia in the same three browsers from Figure 2 (left to right, w3m, Carbonyl, and Firefox).
The other two figures show the real power of Carbonyl, which is that it lets you browse state-of-the-art websites with what is probably the smallest possible load on the hardware, but in the same exact way you, and everybody else who ever surfed the Internet since the 1990s, already know! In Figure 5, I could see the full-size version of the picture in the featured Wikipedia article just by clicking on it.
What you see in the right side of Figure 6, instead, is the pop-up window that appears when you mouse over any link to other Wikipedia pages.
Try doing that in w3m or Lynx! Of course I do not mean to disparage in any way those browsers and their developers here! Those are very different projects, with different goals and plenty of real-world use cases, not competitors of Carbonyl in any way.
The fact is, with Carbonyl you can scroll, point, and click whatever you want with your mouse. Including unavoidable annoyances such as GDPR notifications, cookie configuration windows, pop-ups to accept Terms of Use, or superimposed banners. With just a bit more resolution, even picture-based captchas may be manageable.
As one last example of Carbonyl's usability, let me explain Figure 7, which is the same figure I used in another article in this issue of Linux Magazine [7]. The original purpose of that figure was to show that anyone can embed interactive, very complex web forms to analyze online databases in any web page using iframe HTML elements. In Figure 7, the web page whose source code appears on the left is visualized in Firefox, with its drop-down menu used to select certain columns of the database. Figure 8 shows that if you load the same page in Carbonyl, the embedding and all the elements of the interactive web form, including its zoomable maps tab not shown in Figure 7, will still work!
Through these and other tests, I have found that Carbonyl, while far from being a finished product, already makes complex websites usable just like a non-savvy web user would expect from a "normal" browser, with very satisfying performances on the most common Linux terminals. According to its website, there are people who managed to play Doom on Carbonyl and to use services such as Gmail and Slack.
Carbonyl's low graphical resolution may even be a bonus by helping user's avoid distractions, especially in environments such as school labs or libraries, and I am sure there are many other such opportunities. When I asked on the Carbonyl GitHub page, for example [8], another user reported that his university is using Carbonyl and rclone (a command-line program to manage files on cloud storage, [9]) to "enable users to mount their OneDrive using a fancy script that behind the covers uses rclone [because] the simplest method to enable the drive is to use a web-browser to grant the app access through Microsoft's login portal. It's a clunky solution but it works thanks to Carbonyl!"
Buy this article as PDF
(incl. VAT)