52 lines
9.9 KiB
Markdown
52 lines
9.9 KiB
Markdown
# Bananarchy Linux — agent guide (`AGENTS.md`)
|
|
|
|
## 1. Project overview
|
|
**Bananarchy** is a keypad-first Linux distribution (`armv7` / Alpine `edge` / postmarketOS `v26.06` hardfork) for **Qualcomm MSM8905 (Snapdragon 205)** and **MSM8909 (Snapdragon 210)** smart feature phones with **240x320 QVGA non-touch SPI displays** and **12-key T9 keypads** (`nokia-argon`, `nokia-beatles`, `nokia-tough`, `nokia-sparkler`, `nokia-leo`).
|
|
|
|
It uses a pure **X11 (`Xlibre` + `sxmo-de-dwm`)** stack (no Wayland) with **Adreno 304 (`FD304`) Glamor + DRI3 + GLX GPU acceleration** over `panel-mipi-dbi` KMSRO, optimized for `< 2 ms` UI wakeup latency and `< 95 MB` idle RAM on 512 MB devices.
|
|
|
|
## 2. Repository layout
|
|
- `src/sxmo-dwm/`: patched `dwm` window manager (`240x320` vertical `bstack` layout, 24px Pango status bar, desktop `"Menu"`/`"Names"` softkey bar, C-level `evdev` `SW_LID` slider and universal key wake handling, `*` + `#` screenshot chord via `bananarchy-screenshot`, live `.Xresources` reload, and `.so` plugin loader via `dwm_plugin.h`).
|
|
- `src/sxmo-dmenu/`: zero-lag resident DWM menu plugin (`dmenu.so`) and `/tmp/dwm_plugin_dmenu.sock` client (`dmenu` / `xdmenu`), featuring built-in Sxmo menus (`sys`, `applications`, `scripts`, `modem`, `config`, `power`, `audio`, `notifications`, `wm`, `timezone`, `games`, `st`, `nano`, `sthotkeys`) and `fcitx5-t9` XIM input.
|
|
- `src/neoui/`: **NeoUI** `240x320` UI SDK (`neoui.h` -> `/usr/include/neoui.h`, `neoui.cpp` -> `/usr/lib/libneoui.so`) providing both a C-compatible FFI (`neoui_*`) and C++20 classes (`ThemeSpec`, `PluginTheme`, `NeoWindow`) for `.Xresources` / `~/.xthemes/*.xth` theme resolution, Xlib/Xft/Pango window and offscreen `Pixmap` double buffering, standardized OS shell widgets, keypad/softkey chord handling, and multi-tap input (paired with Yabasic FFI libraries `neoui.yab` and `neonet.yab` + demos `neoui_demo.yab` and `neonet_demo.yab` in `overlay/rootfs/home/user/Projects/`).
|
|
- `src/dwm-plugins/`: preloaded C++20 `240x320` DWM plugins linked against `libneoui.so` and shared headers:
|
|
- `theme.h`: header forwarding to `../neoui/neoui.h` for unified `.Xresources` / `~/.xthemes/*.xth` parsing, proportional font sizing (`theme.baseFontSize`), automatic shade derivation, and live Xft/Pango theme reloading (`PluginTheme`).
|
|
- `phone_data.h`: shared X11 geometry (`240x296` below the 24px bar), FIFO IPC (`/tmp/dwm_plugin_<name>.fifo`), softkey chord detection, Sxmo TSV contact/call/SMS parsers, and `libjpeg`/`libpng` helpers.
|
|
- `net_tls.h`: shared C++20 TCP + OpenSSL TLS + STARTTLS socket class (`NetStream`), HTTP/HTTPS `GET` client (`httpGet`), MD5/CSPRNG helpers, and RFC 2047 / Base64 / Quoted-Printable MIME decoders.
|
|
- `pjsip_media.h`: PJSIP (`pjproject` / `pjmedia-codec/g722` & `pjmedia/alaw_ulaw`) ITU-T G.722 wideband 16 kHz SB-ADPCM and G.711 PCMU/PCMA codec implementation for `sip.so`.
|
|
- `monotone.h` + `bananarchy_melody.cpp` (`/usr/bin/bananarchy-melody`): Nokia RTTTL (`.nrt`, `.rtttl`, `.rtx`), Ericsson eMelody (`.emy`), and IrDA iMelody (`.imy`) monophonic ringtone parser and 48 kHz WAV synthesizer.
|
|
- `locker_plugin.cpp` (`locker.so` / `xlocker`) + `verify_passcode.c` (`/usr/bin/bananarchy-verify-passcode`), `passcode_plugin.cpp` (`passcode.so` / `xpasscode`), `dialer_plugin.cpp` (`dialer.so` / `xdialer`), `calllog_plugin.cpp` (`calllog.so` / `xcalllog`), `callscreen_plugin.cpp` (`callscreen.so` / `xcallscreen`), `contacts_plugin.cpp` (`contacts.so` / `xcontacts`), `sms_plugin.cpp` (`sms.so` / `xsms`), `files_plugin.cpp` (`files.so` / `xfiles`), `camera_plugin.cpp` (`camera.so` / `xcamera`), `themes_plugin.cpp` (`themes.so` / `xthemes`), `modem_plugin.cpp` (`modem.so` / `xmodem`), `networks_plugin.cpp` (`networks.so` / `xnetworks` / `xbluetooth`), `ringtones_plugin.cpp` (`ringtones.so` / `xringtones`), `wallpapers_plugin.cpp` (`wallpapers.so` / `xwallpapers` / `xbackground`), `music_plugin.cpp` (`music.so` / `xmusic` / `xplayer`), `sip_plugin.cpp` (`sip.so` / `xsip`), `email_plugin.cpp` (`email.so` / `xemail` / `xmail`), `irc_plugin.cpp` (`irc.so` / `xirc`), `tox_plugin.cpp` (`tox.so` / `xtox`), `smallweb_plugin.cpp` (`smallweb.so` / `xkopher` / `kopher` / `xsmallweb`), `webarchy_plugin.cpp` (`webarchy.so` / `webarchy` / `xwebarchy`), `gps_plugin.cpp` (`gps.so` / `xgps` / `xmaps` / `xnav`), `privacy_plugin.cpp` (`privacy.so` / `xprivacy` / `privacy`).
|
|
- `dwm_plugin_runner.c`: lightweight `/usr/bin/dwm-plugin` launcher symlinked by `xlocker`, `xpasscode`, `xdrawer`, `xdialer`, `xcalllog`, `xcallscreen`, `xcontacts`, `xsms`, `xfiles`, `xcamera`, `xthemes`, `xmodem`, `xnetworks`, `xbluetooth`, `xringtones`, `xwallpapers`, `xbackground`, `xmusic`, `xplayer`, `xsip`, `xemail`, `xmail`, `xirc`, `xtox`, `xkopher`, `kopher`, `xsmallweb`, `webarchy`, `xwebarchy`, `xgps`, `xmaps`, `xnav`, `xprivacy`, `privacy`, `dmenu`, and `xdmenu`.
|
|
- `src/xdrawer/`: global phone controls overlay (`xdrawer.so` / `xdrawer`), toggled by pressing both softkeys simultaneously.
|
|
- `src/sxmo-st/`: patched `st` terminal with HarfBuzz OpenType ligatures (`Fira Code`), `XIM` (`fcitx5-t9`), and live `SIGUSR1` `.Xresources` reload.
|
|
- `src/fcitx5-t9/`: 6-mode keypad input method (`abc`, `Abc`, `ABC`, `Sym`, `Ctl`, `123` + `*` long-press `Ctrl+` latch) with fixed bottom preedit bar (`Y=290, H=30`).
|
|
- `src/games/`: standalone keypad-driven `240x320` X11 games and emulators (`snake.cpp` -> `/usr/bin/snake`, `tetris.cpp` -> `/usr/bin/tetris`, `scoundrel.cpp` -> `/usr/bin/scoundrel`, `gambatte_phone.cpp` + `gambatte/` -> `/usr/bin/gambatte` / `/usr/bin/gbemu`, and `remedy/` -> `/usr/bin/remedy` / `/usr/bin/j2me` J2ME MIDP 2.0 / CLDC 1.1 + JSR-184 M3G 3D emulator) with built-in 5x7 bitmap fonts, NeoUI integration, `timerfd`-driven pacing, and offscreen `Pixmap` / EGL double buffering.
|
|
- `src/msm8905-cam/` & `src/leds-msm8905-torch/`: out-of-tree Linux `6.12.1-msm8916` kernel modules for the rear `GC2395` / `GC2385` / `GC2365` camera (`/dev/video0`) and `SY7807` torch LED (`white:torch`) / WCD codec init / PM8909 `PON` shutdown.
|
|
- `overlay/rootfs/`: system configuration overlay applied over the target rootfs (kept in sync with `prebuilt/`).
|
|
- `prebuilt/`: cross-compiled `armv7` binaries and kernel modules (`sxmo-x11`, `fcitx5-t9`, `xlibre`, `kernel-6.12.1-msm8916`, `bantam`, `games`, `gsocket`).
|
|
- `devices/` & `patches/`: device trees (`.dts`/`.dtb`), MIPI-DBI panel init sequences, and upstream patch sets.
|
|
|
|
## 3. Build and image generation commands
|
|
All cross-compilation scripts run inside rootless Docker (`alpine:3.24` `armv7` sysroot) and automatically update both `prebuilt/` and `overlay/rootfs/`:
|
|
- `./scripts/build-sxmo-x11.sh` — builds `libneoui.so`, `st`, `dmenu.so`, `dwm`, `dwm-plugin`, `bananarchy-verify-passcode`, `bananarchy-melody`, `sxmo_vibrate`, and all C++ `.so` plugins (`locker`, `passcode`, `xdrawer`, `dialer`, `calllog`, `callscreen`, `contacts`, `sms`, `files`, `camera`, `themes`, `modem`, `networks`, `ringtones`, `wallpapers`, `music`, `sip`, `email`, `irc`, `tox`, `smallweb`, `webarchy`, `gps`, `privacy`).
|
|
- `./scripts/build-gsocket.sh` — fetches and cross-compiles `gsocket` (`gs-netcat`, `gsocket`, `gs-sftp`, `gs-mount`, `blitz`) for `armv7`.
|
|
- `./scripts/build-dmenu.sh` — rebuilds only `dmenu.so`, `stest`, `dmenu_path`, and `dmenu_run`.
|
|
- `./scripts/build-games.sh` — builds standalone X11 games and emulators in `src/games/` (`snake`, `tetris`, `scoundrel`, `gambatte` / `gbemu`, `remedy` / `j2me`).
|
|
- `./scripts/build-fcitx5-t9.sh` — builds `src/fcitx5-t9` (`libt9.so` / `t9.so`).
|
|
- `./scripts/build-kernel-audio.sh` — builds `6.12.1-msm8916` Adreno 304 `drm/msm`, QDSP6 audio, torch LED, camera `.ko` modules, and device `.dtb` files.
|
|
- `./scripts/build-xlibre.sh` — builds Xlibre `Xorg`, `libglamoregl.so`, `libglx.so`, and `modesetting`/`libinput`/`fbdev` DDX drivers.
|
|
- `./scripts/build-bantam.sh` — fetches and cross-compiles the `bantam` AI agent.
|
|
- `./scripts/generate-artwork.py` — regenerates wallpapers, splashes, and icons from `artwork/icon-large.png`.
|
|
- `./scripts/version.sh [--print | target_rootfs]` — computes the date-based release version (`<year-letter><MM><DD>` with `2026 = a`) and substitutes `@BANANARCHY_VERSION@` in `etc/os-release`, `etc/issue`, and `etc/motd` (invoked automatically during overlay application and image builds).
|
|
- `./chroot-shell.sh` — opens an `armv7` container shell to manage packages in `rootfs/` (`pkg-add`, `pkg-del`, `pkg-search`).
|
|
- `./rebuild-image.sh <device> [--mkinitfs]` — applies `overlay/rootfs/` + `prebuilt/` into `rootfs/` and produces flashable images in `images/`.
|
|
- `sudo ./flash-edl.sh [device]` — flashes `lk2nd` and the system image over Qualcomm USB EDL (`05c6:9008`).
|
|
|
|
## 4. Coding and architecture conventions
|
|
- **Indentation**: always use 2-space indentation in C, C++, Python, Yabasic, and shell scripts (tabs only in Makefiles and TSV files).
|
|
- **No emojis**: never use emojis in source code, UI strings, logs, or commit messages (use Nerd Font PUA codepoints defined in `neoui.h` / `phone_data.h` / `dmenu.c` for UI icons).
|
|
- **Unified theming**: never hardcode UI colors or font sizes in `dwm`, `dmenu`, `st`, or any DWM plugin. Read colors and proportional font sizes from `PluginTheme` (`src/neoui/neoui.h` / `src/dwm-plugins/theme.h`) / `.Xresources` (`theme.*`), and handle `RELOAD_THEME` on the plugin FIFO.
|
|
- **Zero-lag plugin model**: phone UI apps must run as preloaded resident daemons (`--preload`) guarded by `/tmp/dwm_plugin_<name>.lock`, sleeping at 0% CPU on `poll()` over `ConnectionNumber(dpy)` and `/tmp/dwm_plugin_<name>.fifo`, and rendering into an offscreen `Pixmap` (`240x296` at `X=0, Y=24`) copied with `XCopyArea` to prevent flicker.
|
|
- **Documentation**: keep `README.md`, `MANUAL.md`, `SDK.md`, and `CHANGELOG.md` synchronized with any new user-facing features, SDK functions, or keybindings, and do not leave third-party `.md` files inside `src/` or `edl/`.
|
|
- **Sentence case**: always use sentence case in subheadings and list items across all documentation files (`README.md`, `MANUAL.md`, `SDK.md`, `CHANGELOG.md`, `AGENTS.md`).
|