etyOS

Nirvana: writing applets

Windows and the registry

The registry entry that lets an applet run, what its window can be asked for, and applets with more than one window.

The registry

The registry is the list of applets that may run. The runtime starts nothing that is not in it.

{
  "default": "settings",
  "applets": [
    {
      "id": "calculator",
      "title": "Calculator",
      "titles": { "ru": "Калькулятор" },
      "manifestPath": "applets/calculator/Cargo.toml",
      "packageName": "calculator",
      "window": { "width": 360, "height": 620, "minWidth": 300, "minHeight": 460 }
    }
  ]
}
FieldMeaning
idWhat the applet is started by (etyde-applet <id>). Lower-case letters, digits and dashes. The window’s app id is etyde-<id>.
title, titlesThe window’s title, and its translations by language code.
manifestPath, packageNameThe crate and its binary. Two entries may share one crate: files and chooser are the same program in two roles, and it tells them apart by NIRVANA_APPLET_ID.
windowHow the window is made (below).
environment"full" lets the applet’s process inherit the whole session environment. By default it gets a short list of variables. A terminal needs "full"; a calculator does not.
mediatrue allows the window to show local pictures, video and sound (MediaView, Preview, thumbnails).
webviewtrue allows <webview> pages inside the window. Only the browser has it.

The window

OptionMeaning
width, heightThe size it opens at.
minWidth, minHeightHow small it may be made.
resizablefalse for a fixed size.
autoSizeThe window follows the size of its content.
keepAliveClosing the window hides it and the applet keeps running, to come back at once.

The shell’s own surfaces (the dock, the lock screen) have a few more options that an ordinary applet has no use for.

Starting an applet

etyde-applet calculator

If the applet is already running, it is asked directly to show its window: no second copy is started.

More than one window

An applet can open further windows. All of them belong to the one process and share its state.

// in event:
"about" => commands.open_window("about", &tr("About"), 420, 280),

// in render:
fn render(&mut self, window: &Window) -> Node {
    if window.role.as_deref() == Some("about") {
        return self.about();
    }
    self.main_page()
}

role is a word of your choosing (lower-case letters, digits, dashes). The first window has no role. window_opened and window_closed tell the applet when windows come and go; when the last one closes, run returns and the process ends. An applet that does not end in time is killed.

Windows that stay ready

With "keepAlive": true in the registry:

  • commands.hide_window() (and the window’s close button) hides the window; the applet keeps running.
  • handle.show_window() brings it back, after a fresh render.
  • Starting the applet with --hidden warms it up without showing it.
  • When it is put away, the applet gets dismiss on @host: the moment to clear what should not be there next time.

This is how the launcher opens within a frame. Use it for things that are called up all day, not for ordinary applications: a kept window is memory held.

Glass

Every Nirvana window has an alpha channel. A component that is glass (the sidebar of a SplitView, the dock, the launcher) is painted with a translucent fill, and the runtime tells YAWC where it is; the compositor blurs what is behind it. Outside YAWC nothing is blurred, and the fill alone reads as a frosted panel.

An applet does not ask for glass: it uses the components that are glass.

Something wrong or missing on this page? Say so in the tracker (choose “Site and docs”).

Esc