minigui
minigui is an experimental library for creating graphical user interfaces from Gleam (Erlang target) using a native external C port.
Status / scope
- Windows: Win32 backend (window + label + textbox + button).
- Linux: GTK3 backend (window + label + textbox + button).
- macOS: for now, headless mode only (simulated).
Note: on Linux the
miniguibinary links against GTK3, so the system must have GTK3 available at runtime (common on desktops; on minimal servers you may need to install packages).
The goal is to keep a small, stable API in Gleam, while enabling native per-platform backends.
Releases / publishing
See the checklist: RELEASING.md
Installation (Gleam Packages)
gleam add minigui
"Build-dependency-free" (precompiled binary)
To avoid requiring your users to install a C compiler or headers (libx11-dev, etc.), minigui is designed to use a precompiled executable as a bridge (a port) and download it automatically into priv/ on first use.
By default it builds the URL like this:
https://github.com/Aztekode/minigui/releases/download/v<version>/<asset>
Where <version> comes from the package vsn (e.g. 0.1.0) and <asset> depends on the OS/architecture, for example:
minigui.exe(Windows x64)minigui(Linux x64)
You can override the download base with:
MINIGUI_RELEASE_BASE_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.2"
If you prefer an exact link like .../minigui.exe, you can set the full URL:
MINIGUI_PORT_URL="https://github.com/Aztekode/minigui/releases/download/v0.1.2/minigui.exe"
Security/cache options:
- By default,
miniguirequiresminigui(.exe).sha256to exist and validates the SHA256. MINIGUI_REQUIRE_SHA=0: disables validation (not recommended).- The binary is cached per user (Linux:
~/.cache/minigui/<version>/, Windows:%LOCALAPPDATA%\\minigui\\<version>\\).
Runtime requirement: a "full" Erlang/OTP installation that includes the standard
inets+sslapplications (they usually ship with OTP; on some Linux distros they may be split into separate packages).
Protocolo (v1)
The port is opened with open_port(..., [{packet, 2}, binary, ...]).
Handshake:
0x00HELLO+u16 version0xF0HELLO_ACK+u16 version+u32 capabilities
Commands:
0x10CREATE_WINDOW+u32 request_id+ UTF-8 title0x11SET_LABEL+u32 request_id+ UTF-8 text0x12SET_TEXT+u32 request_id+ UTF-8 text0x13ADD_BUTTON+u32 request_id+u8 id+ UTF-8 label0x14RUN+u32 request_id0x15QUIT+u32 request_id
Responses:
0x70OK+u32 request_id0x71ERR+u32 request_id+ UTF-8 message
Events:
0x81BUTTON_CLICKED+u8 id0x82CLOSED0x83LOG+ UTF-8 text0x84TEXT_CHANGED+ UTF-8 text0x85KEY_DOWN+u32 keycode0x86ERROR+ UTF-8 text
Build (Linux)
Requirements: gcc, make, pkg-config, libgtk-3-dev, Erlang/OTP, gleam.
Tested with Gleam v1.17.0.
make port
gleam build
make demo
If you're in an environment without an X server (CI/headless), force simulated mode:
MINIGUI_HEADLESS=1 make demo
Build (Windows)
- Compile the port:
make port
- Run the demo:
gleam build
gleam run -m demo
Note: the Win32 code is inside
#ifdef _WIN32.