Chapters

Docs Getting started

Quick start

This chapter takes you from an empty crate to a BifrOSt desktop app: the tools you need, the smallest app that builds, how to build and run it, how to preview it in Light and Dark, and how to pack it for the App Store.

Prerequisites

You need a Rust toolchain with cargo, installed with rustup, and a Linux x86_64 machine. Apps are built for x86_64-linux. The build uses --offline, so the dependencies must already be in your local Cargo cache before you build.

The repository is laid out as follows. Paths are relative to the repository root.

PathContents
springboard/Cargo.tomlThe Cargo workspace. Every app crate is listed in its members array.
springboard/apps/<name>-desktop/One app: Cargo.toml, manifest.toml, icon.png, CHANGELOG.md and src/.
springboard/sdk/The bifrost-app crate. It provides the App trait, run, the kit module and the widgets module.
springboard/ui/The bifrost-ui kit that the SDK builds on.
springboard/render/Colours, type sizes and radii in src/ui.rs.
springboard/proto/The wire protocol between the shell and an app.
tools/pc-app.pyBuilds, packs and publishes an app. It is also run as bifrost pc app.
tools/pc-app-smoke.pyRenders an app on the host. It is run as bifrost pc smoke.
springboard/tools/aap.pyThe packager that writes the .aap file.

Create the crate

Put the app in its own directory under springboard/apps/. Use the suffix -desktop, as the existing apps do. The directory name is the name you pass to pc-app.py and bifrost pc smoke.

The Calculator app, springboard/apps/calculator-desktop, is a complete example. Its Cargo.toml names the crate, sets the version, and depends on bifrost-app by path. Its manifest.toml sets the package fields. Read those two files first, then copy the fields you need.

Create springboard/apps/hello-desktop/Cargo.toml:

[package]
name = "bifrost-hello"
version = "0.1.0"
edition = "2021"

[dependencies]
bifrost-app = { path = "../../sdk" }

Add the directory to the members array in springboard/Cargo.toml:

"apps/hello-desktop"

Create springboard/apps/hello-desktop/manifest.toml:

id           = "is.example.hello.desktop"
name         = "Hello"
version      = "0.1.0"
exec         = "bifrost-hello"
icon         = "icon.png"
min_shell    = "0.4.84"
summary      = "A blank app, the smallest BifrOSt app."
category     = "Utilities"
architecture = "x86_64-linux"
Important

The version in manifest.toml must equal the version in Cargo.toml. pc-app.py refuses to continue when they differ. The exec value must match the binary name, which is the package name, bifrost-hello. The id must match the value that id() returns.

Add icon.png, a 180 × 180 PNG, next to the manifest. Add a CHANGELOG.md with a ## 0.1.0 entry. The Manifest chapter lists every field and permission.

The smallest app

An app is a type that implements the App trait. The trait has one required method, draw. The SDK calls it for each frame, and draw returns the area that changed. This app draws nothing, so it shows a blank surface. Put this code in springboard/apps/hello-desktop/src/main.rs:

use bifrost_app::{run, App, Ctx, Damage, Surface};

struct Hello;

impl App for Hello {
    fn id(&self) -> &str {
        "is.example.hello.desktop"
    }

    fn draw(&mut self, _ctx: &Ctx, s: &mut Surface, _t: f64) -> Damage {
        let mut d = Damage::new(s.w, s.h);
        d.all();
        d
    }
}

fn main() {
    run(Hello);
}
run<A: App>(app: A)
Starts the app. It reads the socket that the shell passes in BIFROST_SOCK, then serves events and frames until the shell quits the app.
App::id(&self) -> &str
The reverse-DNS identifier. It must match id in manifest.toml.
App::draw(&mut self, ctx: &Ctx, surface: &mut Surface, t: f64) -> Damage
Draws one frame into surface. t is the time in seconds. Return the areas that changed since the last frame.
Damage::new(w, h) and Damage::all()
Create the damage record for a surface of w by h pixels. all() marks the whole surface as changed.
Note

The SDK defines more methods with defaults. You override only the ones you need. event receives touch, key and menu input. configure receives the size and the appearance. main_menu and menu_action add items to the menu bar. Use the UI kit chapter to draw real content.

Build and run

Build the app from springboard/:

cd springboard
cargo build --offline --profile fast -p bifrost-hello --bin bifrost-hello

The fast profile is the optimized incremental profile that the desktop uses for day-to-day builds. The binary is written to springboard/target/fast/bifrost-hello.

Or let the packaging tool run the same build. It takes the directory name:

python3 tools/pc-app.py build hello-desktop
bifrost pc app build hello-desktop

The binary does not run on its own. The SDK expects the shell to pass the socket in BIFROST_SOCK, and it exits with status 2 and a message when that variable is missing. The shell starts an installed app and sets that variable. To run the app on the desktop, pack it, install the package, and restart the shell (see Pack and publish). The shell registers installed apps when it starts, so a newly installed app appears after a restart.

Note

The build uses --offline. If Cargo reports a missing crate, fetch the dependencies once with a network connection, then build again.

Preview in Light and Dark

A host preview runs the real app binary on your machine and writes what it draws to PNG files. You do not need a running desktop. The preview runs in Dark by default. Add --light for Light.

bifrost pc smoke hello-desktop --sizes 1200x780 --scale 1.5625
bifrost pc smoke hello-desktop --light --sizes 1200x780 --scale 1.5625
OptionMeaning
APPThe app directory name under springboard/apps/. You can pass several.
--lightStarts the app in the Light scheme. The file names end in -light. Without it, the preview is Dark.
--sizes WxH,...The window sizes to render, in pixels. The default is 1000x720,900x600.
--scale NPixels per point. The default is 1.0. A value of 1.5625 gives a 1200 × 780 window at 768 points wide.
--out DIRThe output directory. The default is out/pc-app-smoke.

Check each preview in both schemes. The SDK widgets follow the scheme, and so should your app. Open the PNG files and compare them with the design rules before you publish. The bifrost pc gallery command renders every SDK widget in both schemes, so you can compare your widgets with them.

Note

The preview checks rendering and resizing only. It does not test the installed sandbox, the portal, or audio hardware.

Pack and publish

tools/pc-app.py has three actions. Each one builds the app first, unless you pass --skip-build to publish.

CommandWhat it does
python3 tools/pc-app.py build hello-desktopBuilds the binary and prints its path.
python3 tools/pc-app.py pack hello-desktopBuilds, strips the binary, and writes out/pc-apps/is.example.hello.desktop-0.1.0.aap. The package is for local testing only.
python3 tools/pc-app.py publish hello-desktopPacks the app and sends the package to the PC App Store with publish-app.sh. Publishing needs access to the store and is for maintainers.

To try a packed app on a desktop, install the local package as root and restart the shell:

sudo springboard --install-package out/pc-apps/is.example.hello.desktop-0.1.0.aap
Important

Install with springboard --install-package only on a machine you are allowed to change. The command requires root and writes to the shell's data directory. Use publish for apps other people install.

A package is an uncompressed tar file. It holds manifest.toml, the executable, the icon and an optional assets/ directory. The packer rejects a package whose manifest is missing a required field.

Each release bumps the version in manifest.toml and Cargo.toml together, and adds a CHANGELOG.md entry for the new version. The shell installs a new version beside the old one, so a failed update can be rolled back.

Next steps

Use the layout of a stock macOS app for a new app. Use a sidebar or a list for navigation, one tint colour, and no custom dashboards. Make a sidebar app a full-size window with window = "full-size" in the manifest. The UI kit chapter describes the widgets for that layout.