Contribute to Compás
Compás is built on the belief that portable audio should be modular, extensible, and completely open. Contributors can build and test plugins, themes or Now Playing layouts, then share them through the catalog.
How to Create a Compás Plugin
Plugins are written in Lua and run in the Compás player. They can add features such as streaming sources, audiobook tools, sound controls, utilities, and screens. Installing or updating a plugin does not require a firmware reflash.
1. Plugin Directory Structure
Every plugin lives in its own subdirectory inside the plugins/ folder of the plugin catalog repository:
plugins/
YourPlugin/
YourPlugin.lua -- Main Lua script (defines metadata, hooks, and logic)
store.json -- Store metadata (description, category, extra assets)
preview.png -- Optional preview screenshot (shown in Plugin Store)
data_file.txt -- Optional extra files deployed to the SD card
2. Defining Plugin Metadata (plugin.define)
At the top of your YourPlugin.lua script, declare a unique identifier, display name, version number, and (when needed) minimum API version:
-- YourPlugin.lua
plugin.define({
id = "org.compas.your_plugin", -- Immutable unique ID (used for saved settings)
name = "Your Plugin Name", -- Display name shown in UI
version = "1.0.0", -- Semantic version (increment on updates)
api_min = 2, -- Required for plugin.storage and HTTP requests
})
-- Store a non-secret preference, such as the last successful sync time
local last_sync = plugin.storage.get("last_sync", "never")
-- Optional capability check for asynchronous HTTP requests
if plugin.has_capability("network.http.async") then
-- Use the documented asynchronous HTTP API
end
3. Creating the Store Manifest (store.json)
The store.json manifest informs the on-device Plugin Store how to categorize your package and where to place auxiliary files on the player's microSD card:
{
"description": "Short, clear summary of what your plugin does on the player.",
"category": "Listening",
"author": "Your Name",
"files": [
{ "src": "data_file.txt", "dest": "data_file.txt", "keep": true }
]
}
* Valid categories: Listening, Audio, Customization, Reading, Tools, Experimental, Developer.
* Set "keep": true for user-editable files (like station playlists or configuration files) so updates will not overwrite them.
4. Step-by-Step Testing & Submission Workflow
-
Test locally on physical hardware or simulator:
Copy the plugin
.luafile toSD/.plugins/on your microSD card. Copy any companion files to the destinations listed in its package. Then open Settings → System → Plugin Manager and select Refresh Plugins. -
Verify repository integrity:
Run the catalog validator locally to check package metadata and files:
python3 -m pip install Pillow==12.3.0 && python3 tools/build_index.py --check
-
Submit your Pull Request:
Push your branch to GitHub and open a Pull Request against
Starnished66/compas-plugins. After review and merge, the catalog maintainers can publish your plugin through a catalog release for the on-device Plugin Store.
How to Create a Theme
Themes change colors and interface styling across the player. A theme is selected in the built-in picker; it does not need a running Lua plugin.
- Start from an existing theme. Use a catalog example such as CherryNoir to see the supported settings and package structure. Give your theme its own name.
- Test the appearance. Copy your
.themefile toSD/Themes/and select it under Settings → Display → Appearance → Themes. Check text, icons, selected rows and controls across the player, including light and dark artwork. - Include a representative preview. Put a matching PNG beside the theme with the same filename, such as
MyTheme.themeandMyTheme.png, so the picker can show it. - Share it through the catalog. Follow an existing theme package's
store.jsonto place its files inThemes/. Submit the package to the compas-plugins repository for review.
How to Create a Custom Now Playing Layout
Now Playing layouts govern how cover art, track typography, seek bars, synchronized lyrics, and transport controls are arranged on the player's display. Layouts are defined in LVGL XML. A plugin can optionally register a layout with Lua; standalone XML layouts do not need a registration script.
1. Multi-Resolution Display Specifications
This example uses R1-sized coordinates (480 × 800). Treat it as an R1 starter: add and test screen variants for other supported devices before publishing a multi-device layout.
| Target Hardware | Display Resolution | XML Variant Naming |
|---|---|---|
| HiBy R1 | 480 × 800 (Portrait) | your_layout.xml (Base default) |
| HiBy R3 Pro II | 480 × 720 (Portrait) | [email protected] |
| HiBy R3 II (2025) | 320 × 480 (Portrait) | [email protected] |
2. Declarative XML Layout Architecture
A layout is an LVGL XML component. The player recognizes a small set of named widgets for playback behavior; animations are optional.
<component>
<view extends="lv_obj" width="#screen_w" height="#screen_h" scrollable="false">
<!-- Cover art: required. Tapping it toggles lyrics. -->
<lv_obj name="cover_card" x="24" y="52" width="432" height="340" style_radius="14" style_clip_corner="true">
<lv_image name="cover_img" src="default_cover" align="center" />
</lv_obj>
<!-- Track title: required. -->
<lv_label name="title" x="24" y="408" width="432" height="32" style_text_font="player_title" style_text_align="center" />
<lv_label name="artist" x="24" y="444" width="432" height="28" style_text_font="player_meta" style_text_align="center" />
<!-- Seek control: required. -->
<lv_slider name="progress_slider" x="24" y="500" width="432" height="30" />
<!-- Optional previous, play/pause, and next controls. -->
<lv_image name="prev_btn" src="btn_prev" x="100" y="590" width="48" height="48" />
<lv_image name="play_btn" src="btn_play" x="216" y="584" width="60" height="60" />
<lv_image name="next_btn" src="btn_next" x="332" y="590" width="48" height="48" />
</view>
</component>
3. Companion Lua Layout Registration
Lua is optional for an XML layout: the Player Layout picker discovers XML files placed in SD/.plugins/player_layouts/ or a plugin bundle's player_layouts/ folder. Use a Lua plugin when you want to register plugin-owned actions for the layout; calling plugin.set_player_layout adds the layout to the picker. Custom layout actions require the API 17 ui.player_actions capability.
-- YourLayoutPlayer.lua
plugin.define({
id = "org.compas.your_layout_player",
name = "Your Layout Player",
version = "1.0.0",
api_min = 15, -- XML layout registration is available from API 15
})
local LAYOUT = {
id = "plugin.your_layout_player",
xml = "YourLayoutPlayer/player_layouts/your_layout.xml",
name = "Your Layout Player",
}
if plugin.has_capability and plugin.has_capability("ui.player_layout_xml") then
-- Registers layout; the engine discovers board-size variants automatically
plugin.set_player_layout(LAYOUT)
end
4. Packaging & Submitting Layouts
-
Test the XML-only layout:
Copy the XML file to
SD/.plugins/player_layouts/, or put it in a plugin bundle'splayer_layouts/folder. For the example's R1 coordinates, add[email protected]and[email protected]variants and test each target. - Activate the layout: Open Settings → Display → Player Layout → Layout and select your design. The picker discovers XML files automatically; Lua registration is not needed unless the layout uses plugin-owned actions.
-
Submit for community distribution:
Open a Pull Request to the
compas-pluginsrepository to propose your layout for the downloadable catalog.
Community Guidelines & Quality Standards
- Keep callbacks responsive: Plugin callbacks run under a time limit. Avoid long-running work in callbacks; use the documented APIs and events.
- Battery Efficiency: Do not poll APIs in rapid loops. Use event callbacks and respect system suspend states.
- Touch-Friendly Design: Keep touch targets large enough to use comfortably on compact player screens.
- Open Source Licensing: Check the contribution repository’s licensing requirements before submitting plugins, themes or layouts.