Hello again! I want to start doing “Status update” style articles and more writing in general so I thought I’d announce on here the main project I’ve been working on recently amongst all my other open source work.

Magnolia is a new UI toolkit written entirely from scratch in Zig for Linux desktops. It has a focus on ease-of-use, performance, and supporting older devices. The only runtime system dependencies are X11 and OpenGL. The only additional build dependencies are Git, Zig, and Zigmod.

Zig is a new general-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.

Zigmod is a package manager for Zig I created when I first joined the community in early Nov 2020 and have been maintaining ever since.

The original inspriation for this project came from a variety of places. I’ve been doing a lot of work with Zig and it seemed perfect for the goals I had in mind. Fast compilation speeds, small binaries, simple and cohesive features, powerful compile-time metaprogramming, and a culture dedicated to making software that works well for the user. My specialty in programming for some time has been full stack web development but I have had an itch to make desktop-native apps for a while. At the same time I knew I did not want to make anything with Electron. I have a Pinebook Pro that I want to start using a lot more and it only has 4 GB of RAM. Simply running Firefox and VSCode is enough to use nearly all of its system resources. I find this unacceptable and I think a lot of other people would to, provided they were given the right tools.

The post that really got me to sit down and start working was Flatpak Is Not the Future by Nicholas Fraser. Here he recounts an experience trying to download and run KCalc, a simple calculator app from KDE, through various means. KCalc itself is only 4.4 MB in size, yet the default download methods listed ask the user to allot 900 MB of network and disk space. All this data slows down your apps and your computer for bad reasons. Apps should be getting smaller and faster, not the other way around. Magnolia is one girl’s attempt at trying to turn that cuve around.

Note: this project is a WIP and still in a very experimental state. The purpose of this article is less about asking for users or contributors just yet, but more “just starting” the word of the project on this blog so that I have something to continue off of when posting updates, as opposed to recounting its entire history thus far which I’m about to do while its still incredibly new. I have been working on this for about a month or two now, and while I have made some good progress there’s still a lot more to do which I’ll post about here later.

The first commit was made on 25 Apr 2022.

triangle-raw was created to show off the classic 2D triangle hello world with direct OpenGL and X11 calls.

image

triangle made shortly after to show the same but now made with Magnolia primitives.

image

demo-centersquare handle window resize events and keep a red square in the middle of the screen

image

demo-focusblur handle focus/blur window events and make the screen green/red accordingly

image image

demo-layout a showcase of the StrictGrid component

image

demo-layout2 a showcase of the DynGrid component with a more typical app shell look

image

demo-margin simple demo showing off the beginnings of the style system

image

demo-text a showcase of the TextLine component with from-scratch BDF font parsing/rasterization

image

demo-centersquare2 a reimplementation of demo-centersquare but now implemented with Magnolia intrinsics and the *align style attributes

image

demo-text2 a showcase of the TextFlow component with Lorem Ipsum. (definitely some room for improvement here, text is super hard and will definitely get standalone followup articles)

image

Part of my hope with this project is to bring back the idea that desktop-native apps on Linux can be fast, easy to use, accessible to develop, and maintain a small footprint.

[nix-shell:~/dev/magnolia-desktop]$ zig build --prominent-compile-errors -Dall -Drelease-safe -Dstrip

[nix-shell:~/dev/magnolia-desktop]$ ls -lh zig-out/bin/
total 1.1M
-rwxr-xr-x 1 meg users  26K Jun 18 17:28 magnolia-demo-centersquare
-rwxr-xr-x 1 meg users  60K Jun 18 17:29 magnolia-demo-centersquare2
-rwxr-xr-x 1 meg users  26K Jun 18 17:28 magnolia-demo-focusblur
-rwxr-xr-x 1 meg users  61K Jun 18 17:29 magnolia-demo-layout
-rwxr-xr-x 1 meg users  59K Jun 18 17:29 magnolia-demo-layout2
-rwxr-xr-x 1 meg users  60K Jun 18 17:29 magnolia-demo-margin
-rwxr-xr-x 1 meg users 141K Jun 18 17:29 magnolia-demo-text
-rwxr-xr-x 1 meg users 139K Jun 18 17:29 magnolia-demo-text2
-rwxr-xr-x 1 meg users  26K Jun 18 17:28 magnolia-triangle
-rwxr-xr-x 1 meg users  19K Jun 18 17:28 magnolia-triangle-raw

This ease of building from source is another key requirement for this project that Zig provides for us, because prior to Magnolia apps becoming properly available on the different package repositories for the various distributions, building from source will likely be the only way for many users to get to experience these apps. Pre-packaging distribution-agnostic graphical applications on Linux is a not very solved problem. Some solutions are hacky, and some lead to the bloat mentioned in the post above about Flatpack. A good primer on this topic (which was actually unknown to me for quite some time) is this video by Andrew Kelley, the creator of Zig.

There’s much on the horizon. Immediately so, there’s icons, more text work, more styling demos, and the beginnings of a calculator, filebrowser, and system resource monitor.

Well that’s all I have for today, stay tuned!

If you’d like to follow along check back here or read more of my source on Github https://github.com/nektro/magnolia-desktop or Sourcehut https://git.sr.ht/~nektro/magnolia-desktop.

I also have a Twitter thread and am on Github Sponsors if you’d like to support my work.

Thanks for reading! :D