An external app is a native program on the SD card. More > External Apps lists it, and the player runs it full screen with direct access to the screen and the buttons. Use it for things a plugin cannot do, such as a game, a viewer or a tool that draws its own screen.
Folder layout
Each app has its own folder on the SD card:
<SD card>/.apps/<id>/app.json
<SD card>/.apps/<id>/<exec> the program
<SD card>/.apps/<id>/icon.png optional
<SD card>/.apps-data/<id>/ the app's own files, made by the player
The folder name must equal the id in app.json. The screen is rescanned every time you open it. The player lists up to 32 apps, sorted by name, and skips folders that start with a dot or that are not valid (the reason goes to the player's log).
Plugins can read these folders but cannot write to .apps, .apps-data or .emulators, nor to the approval file /usr/data/apps_approved.txt and its .tmp.
app.json
A minimal working file:
{
"protocol": 1,
"id": "hello",
"name": "Hello App",
"version": "0.1",
"exec": "hello",
"icon": "icon.png",
"opens": ["txt"]
}
| Field | Rule |
|---|---|
protocol | Required. Must be 1. |
id | Required. Lower-case letters, digits, _ and -; starts with a letter or digit; 1 to 32 characters. Must match the folder name. |
name | Required. Shown in the list. Up to 64 bytes, no control characters. |
version | Required. Up to 31 bytes. Shown after the name. |
exec | Required. File name of the program inside the app folder: at most 63 bytes, no / or \, not . or .., and a regular file (not a link). |
icon | Optional. A .png file name in the app folder. If the file is missing, the player uses its stock icon. |
opens | Optional. Up to 8 file extensions, lower case, no dot, up to 7 characters each. Only used when a plugin launches the app with a file. |
boards | Optional. 1 to 8 board ids, up to 15 bytes each (lower case, digits, _, -). The app is listed only on those boards; without the field, on every board. An empty list hides the app, and an unknown id never matches. |
free_player_memory | Optional, true or false. When true, the player drops its rebuildable caches before the app starts. Use it if the app needs a lot of memory. |
Board ids: r1, r3proii, r3ii_2025, tempotec_v1. The file can be at most 16 KiB.
The program must be a static, little-endian MIPS ELF executable. The player ignores scripts and dynamically linked programs. Wrong or missing fields hide the app.
Build a static program
The player is built with mipsel-linux-musl-gcc. The example app is built like this:
mipsel-linux-musl-gcc -static -O2 -o hello hello.c
The player is linked with -static -no-pie and compiled with TARGET_CPU_FLAGS (-march=mips32r2 -mabi=32 -mfp32 -mno-odd-spreg -ffp-contract=off), which are known to run on every board. Copy the result and app.json to .apps/hello/.
Example
Download hello-app.zip. It has hello.c, its app.json and a ready-built hello; copy the hello folder to .apps/ on the SD card. The app paints the screen, counts down 10 seconds with a row of bars, and exits early on any key or touch.
First run and approval
The first time you start an app, the player asks Run <name>? with the warning "External apps have full access to the player." and the buttons Run and Cancel. Run saves the approval and starts the app.
The approval is the app id plus the SHA-256 of the program file. It is kept on the player's internal storage, not on the SD card. Changing the program file (an update, a rebuild), the id or the exec name asks again. Changing only app.json or other files does not.
When an app runs
The player checks these things after you approve, and shows a message when one fails:
| Message | Cause |
|---|---|
| Emulator store is busy. | An emulator install or removal is running. |
| Check the SD card and disconnect USB storage before running apps. | No usable SD card, or the player is in USB storage mode. |
| Turn off DAC mode to run apps. | Wi-Fi, Bluetooth or USB DAC mode is on. |
| USB storage is busy. | The player could not detach the card from USB. |
| Audio is still active; cannot start the app. | Playback did not stop within 2 seconds. |
Before it starts, the player stops playback. It does not resume by itself; Play continues from the saved position. While the app runs, an idle USB storage connection is unbound, and it is bound again afterwards. The player then starts the program:
- Working directory: the app folder.
argv[1]: the file to open, only when a plugin passed one. Launching from the list passes none.- Runs as the player's user (root), in its own process group.
- Standard input is
/dev/null. Standard output and error go to.apps/.last-session.logon the SD card, replaced on every launch. - Screen and input: the app opens
/dev/fb0and the input devices itself. The example app maps the framebuffer and reads/dev/input/event*. Other open files are closed before it starts. - The framebuffer is page-flipped: draw at the current
yoffsetor pan yourself (the example does). The player restores the mode and pan afterwards. SIGPIPEis ignored in the player, and the app inherits that.oom_score_adjis 500.
Environment variables, added to the player's own:
| Variable | Value |
|---|---|
COMPAS_APP_PROTOCOL | 1 |
COMPAS_APP_ID | The app id. |
COMPAS_APP_DATA | <SD card>/.apps-data/<id>, already created. Keep the app's files here. |
COMPAS_BOARD | The board id. |
COMPAS_SCREEN_WIDTH, COMPAS_SCREEN_HEIGHT | The screen size in pixels. |
While the app runs, the player's screen, buttons, screen timeout and idle shutdown are paused. Network and library work continue. Playback is stopped, because the app owns the audio device. There is no time limit.
Returning to the player
The app returns control by exiting. Exit code 0 is a normal close. A non-zero code or a crash shows "The app closed unexpectedly." "Could not start the app." appears when the program cannot be started, when the app changed or vanished between approval and start, or when .apps-data/<id> cannot be created. "Could not save the approval." appears when the approval cannot be written.
When the app ends, the player kills the app's process group (a child that calls setsid or setpgid escapes), restores the screen mode and the backlight, and redraws. A crashed app cannot leave the screen dark. The app must provide its own way to exit, because the player does not read the buttons meanwhile. The example app exits on any key or touch, or after 10 seconds.
Launch from a plugin
A plugin can list and start apps. Check the capabilities apps.list and apps.launch first. See External apps in the plugin guide.
for _, app in ipairs(plugin.list_apps()) do
print(app.id, app.name, app.version, table.concat(app.opens, ","))
end
-- from a list row or menu callback:
local ok, reason = plugin.launch_app("hello", plugin.sd_root() .. "/Notes/todo.txt")
if not ok then plugin.show_toast(reason) end
plugin.list_apps()returns{ id, name, version, opens }for the apps that run on this board.plugin.launch_app(id [, path])only works from a user action, once per action. The action is used up before any check, so a failed call cannot be retried in the same callback. It returnstrue, ornil, reason. The app starts after the call returns, and the checks above then run, so those failures appear as player messages, not as a return value.pathmust start with exactlyplugin.sd_root()(the/usr/data/mnt/sd_0alias is refused), with no.,..or empty (//) parts. Its extension must be in the app'sopens(case does not matter).- Reasons: "no such app", "path must be a file on the SD card", "path is too long", "the app does not open this kind of file", "no such file", "another app is waiting for approval", "out of memory" and "plugin.launch_app only works once from a user action of the calling plugin".