Why a Handheld Needs Its Own Launcher
When you build a pocketable gaming console around a Raspberry Pi Zero or Raspberry Pi Zero 2 W with a 320×240 SPI display and 16 physical buttons, a standard Linux desktop environment is completely out of place. Desktop shells expect a mouse pointer, high-resolution monitors, and hundreds of megabytes of RAM — resources you simply cannot spare when running games on a 512 MB board.
That is why I built
pigogui:
a dedicated, controller-first handheld launcher written in MicroPython and
powered by LVGL 9.3 (Light and Versatile Graphics Library). Instead of
pulling in Electron, Qt, or a full Python/Pygame stack, pigogui runs inside a
tiny 4 MB MicroPython heap directly on Wayland and boots straight into a
smooth 60 FPS console interface.
Purpose: More Than Just a Game List
pigogui is not merely a menu that spawns executables. Its purpose is to make the
PiGo feel like a cohesive, self-contained gaming handheld from the moment you flip the power
switch:
- First-Boot Setup Wizard: Guides new users through language, theme color (dark/light mode + LVGL accent palette), Wi-Fi connection, and timezone configuration.
-
Game Library & Carousel: Automatically discovers installed games in
/opt/pigo/games/, displays cover art, screenshots, and metadata, and launches them with per-game button mappings. - In-Game Quick Menu & HUD: Pauses and resumes running games on demand, while providing floating overlays for volume, display brightness, notifications, and real-time battery status.
- Built-In Store & OTA Update Checks: Downloads pre-packaged games directly from GitHub Releases and checks for launcher updates in the background.
- Full System Settings: Lets you configure Wi-Fi, Bluetooth, display brightness and sleep timers, audio volume, storage, SSH, and system updates without ever touching a terminal.
How the Code Is Structured
The repository follows a clean separation between a presentation layer
(gui/), a manager and system-integration layer
(libs/), and static configuration and assets
(data/, fonts/, audio/).
Entry Point & Wayland Bootstrapping
Launching starts in start.sh, which configures SDL2 to render natively over
Wayland and assigns the application ID pigogui so the Sway compositor recognizes
it as a floating, sticky HUD:
PIGO_PATH="$(dirname -- "${BASH_SOURCE[0]}")"
cd $PIGO_PATH
SDL_VIDEODRIVER=wayland SDL_APP_ID=pigogui micropython -X heapsize=4M $PIGO_PATH/main.py
Inside main.py, the launcher creates a 320×240 ARGB8888 LVGL SDL
window, hides the cursor via SDL_ShowCursor(0), loads the user's theme from
data/configuration.json (falling back to data/configurationDefault.json),
initializes all core managers through SingletonsClass(), and enters a
uasyncio loop ticking every 16 ms (~60 Hz) to pump lv.timer_handler()
and keyboard input.
The Manager & FFI Layer (libs/)
libs/Singletons.py wires up nine singleton managers that share state across the
entire UI:
-
ffishell.py: Because MicroPython's Unix port is intentionally minimal, this module binds directly tolibc.so.6via MicroPython'sffimodule — exposingfork,execv,kill,waitpid,popen,setenv, and low-levelopen/ioctl/read/writesyscalls. -
ApplicationManager.py: The heart of game execution. It starts games withfork()andexecv(), freezes and unfreezes them using POSIXSIGSTOPandSIGCONTwhen the user presses the Home button (mapped toSDLK_DELETE), and restartsuinput-pigo-mapperwith either the game's customkeymapor the launcher'sdefaultKeyMap(always appendingmandatoryKeyMapso hardware shortcuts never stop working). -
DataManager.py: Merges user preferences withconfigurationDefault.json, scans/opt/pigo/games/for subdirectories containing agame.jsonmanifest, and runs non-blockinggit fetchupdate checks vialibs/threading.py. -
BatteryManager.py: Talks directly to PiGo's onboard battery ADC over/dev/i2c-1(I2C address0x50) usingioctl(I2C_SLAVE). Every 3 seconds it reads a 12-bit sample, smooths it over a 20-sample rolling window, and calculates both battery voltage (3.0 V – 4.2 V) and state-of-charge percentage. -
PageManager.py: Maintains a navigation stack with animated LVGL screen transitions across all pages, includingEmptyPage, which hides the launcher cleanly while a game runs fullscreen underneath. -
DownloadManager.py&libcurl.py: Uses FFI bindings tolibcurlto stream game archives listed indata/store.jsondirectly to disk with live progress tracking. -
AudioManager.py,WifiManager.py,SoundDisplayBarManager.py, andNotificationManager.py: Handle UI sound effects (via CLI players such asmpg123), NetworkManager Wi-Fi scanning, brightness/volume HUD bars, and toast notifications.
Pages, Components, and Assets (gui/, fonts/, audio/)
The UI is organized into modular LVGL screens under gui/pages/ — including
LaunchScreenPage, GamesOverviewPage, GameDetailsPage,
StorePage, SettingsPage (with nine dedicated subpages under
SettingsSubPages/), and the six-step setup/ wizard. Reusable
widgets live in gui/components/ (such as GamesCarousel,
BatteryIndicator, TopBar, BottomBar,
SoundBar, and DisplayBar), backed by generic focusable controls in
gui/components/Generic/. Pre-rendered bitmap fonts (baloo_chettan
and ubuntu) and lightweight .ogg sound effects keep rendering sharp
and responsive on the small screen.
Role in the PiGo Handheld Ecosystem
Within the PiGo software stack, pigogui is the console shell and
orchestrator. While pi-gen-pigo builds the OS image and
pigo-config sets up the kernel overlays and Sway compositor,
pigogui is what turns that Linux environment into a real handheld experience: it
reads hardware sensors over I2C, orchestrates uinput-pigo-mapper on every game
switch, consumes packaged titles from pigo-games, and gives the player instant
control over games and hardware settings with zero keyboard or mouse required.

