Documentation / LemmeKnow

Building plugin packages

A plugin package is a .lkplugin file that adds content to LemmeKnow: themes, textures, fonts, sounds, Delivery Screens and notification cards. It's an ordinary zip archive with a manifest.json at its root. Packages carry content only. The only code a package can run is the JavaScript inside its Delivery Screens, which runs sealed off from the network and filesystem writes (see Delivery Screen pages).

Users install packages from Settings, Install Plugin Package, which is a Premium only feature. See Plugins on your phone for what the user sees.

The Backdrop package is a complete working example used throughout this page. Download it and unzip it to follow along.

Package layout

Put manifest.json at the top of the archive. Every other file can sit anywhere, at any depth, and is referred to by its path relative to the archive root. Backdrop looks like this:

backdrop.lkplugin
  manifest.json
  delivery/backdrop/screen.html
  delivery/backdrop/texture.js

A package is refused at install if:

  • it has no manifest.json, or the manifest isn't a JSON object;
  • any entry's path contains .. or a backslash, starts with /, or would land outside the package;
  • it has more than 2,000 files, or unpacks to more than 100 MB;
  • the manifest has no valid id;
  • the manifest declares webviewPage, execScript, or action (those are for hub plugins only);
  • contributes has no entries at all.

Any declared file path that would resolve outside the package's folder is skipped.

manifest.json

{
  "id": "example.sunrise",
  "name": "Sunrise",
  "label": "Sunrise pack",
  "description": "Warm colors, a sun texture and a chime.",
  "version": "1.2.0",
  "contributes": {
    "themes": [],
    "textures": [],
    "fonts": [],
    "sounds": [],
    "deliveryScreens": []
  }
}
FieldRequiredMeaning
idYesThe package's permanent identity. Letters, digits, _, . and - only. Installing a package with the same id replaces the installed one, so keep it stable across versions.
nameNoInternal name. Defaults to id.
labelNoThe name users see in pickers and the review dialog. Defaults to name.
descriptionNoShown in the review dialog.
versionNoA version string, shown in the review dialog.
contributesYesThe content the package adds. At least one of the five lists must have an entry.

The review dialog shows these as Id, Internal name, Name, Description, and Version.

Referring to your own files

Inside your package (for example, a theme that uses your own texture or font), refer to a contributed asset as:

plugin:import:<package id>:<asset id>

So a texture with "id": "sun" in the package example.sunrise is plugin:import:example.sunrise:sun.

Textures, fonts, and sounds

These three lists share one entry shape:

"textures": [
  { "id": "sun", "label": "Sun", "file": "textures/sun.png" },
  { "id": "sparkle", "label": "Sparkle", "file": "textures/sparkle.gif" }
],
"fonts": [
  { "id": "rounded", "label": "Rounded", "file": "fonts/rounded.ttf" }
],
"sounds": [
  { "id": "chime", "label": "Chime", "file": "sounds/chime.ogg" }
]
FieldRequiredMeaning
idYesUnique within its list. Used in plugin:import:... references.
labelNoName shown in pickers. Defaults to id.
fileYesPath to the file inside the package.
hashNoExpected hash of the file, such as "sha256:<hex>". See Hashes below.

Animated GIF textures are offered when the texture type is GIF, other images when it's Image. For where each kind shows up once installed, see What plugin content adds.

A Delivery Screen in the same package can also load these files directly as _plugin/<file> (see Delivery Screen pages).

Themes

A theme is written inline in the manifest, with no file of its own.

"themes": [
  {
    "id": "sunrise",
    "name": "Sunrise",
    "description": "Warm and bright",
    "version": 1,
    "paletteMode": "animated",
    "paletteColors": ["#FF8A3D", "#FFC94D", "#FF5E7A"],
    "waveMode": "wave",
    "waveAngle": 0,
    "colors": {
      "ACCENT": "#FFFF8A3D",
      "BG_APP": "#FF1A1210",
      "BG_SURFACE": "#FF261A16",
      "TEXT_PRIMARY": "#FFFFF4EC"
    },
    "styles": {
      "screen": {
        "textureType": "image",
        "textureContent": "plugin:import:example.sunrise:sun",
        "textureTileMode": "single",
        "textureOpacity": 0.4
      },
      "card": { "cornerRadiusDp": 12, "borderWidthDp": 1 }
    },
    "fontFamily": "plugin:import:example.sunrise:rounded"
  }
]

The easiest way to write a theme is to build it in the app and export it: on the Themes tab, the download icon on the current theme card saves it as a .lkplugin with its images bundled. Unzip that file and you have a correct manifest to start from.

FieldMeaning
idRequired. Unique within the package.
nameRequired. The theme's name in the list.
descriptionOptional text on the theme card.
versionTheme format version. Use 1. Defaults to 1.
paletteModestatic (no animation), animated (animate paletteColors), or rgb (animate a full rainbow). Defaults to static.
paletteColorsThe palette as a list of #RRGGBB colors.
waveModepulse, wave, ping_pong, breathe, or chaos. Leave it out to use Pulse.
waveAngle0 to 359, the Wave and Ping-pong direction (0 is right, 90 is down). Leave it out to keep the user's angle.
colorsColor overrides keyed by the app's color names (such as ACCENT, BG_APP, BG_SURFACE, TEXT_PRIMARY, TEXT_DIM, ALERT_ACCENT), as #RRGGBB or #AARRGGBB. Every color you leave out uses its default.
stylesElement styles keyed by element (table below). Elements you leave out use their default style.
windowLinkedfalse to style the top and bottom bars separately with windowTopStyle and windowBotStyle. Defaults to true.
windowTopStyle, windowBotStyleElement styles for each bar when unlinked.
statusBarIcons, navBarIconslight or dark system icons over the top and bottom bars. Default light.
fontFamilyEmpty for the system font, a family name such as serif or monospace, or a plugin: font reference.

Element keys for styles:

KeyElement in the Style tab
monitor, dashboard, editor, screenMonitor BG, Dashboard BG, Editor BG, Settings BG
surface, insetSurface, Inset
windowWindow Bars
card, list_item, log, sectionCard, List Item, Log Row, Section
badge, chip, inputBadge, Chip, Input
button, destructive, fabButton, Destructive, FAB

Element style fields (all optional; the default is shown):

FieldDefaultMeaning
cornerRadiusDp0Corner radius
borderWidthDp0Border width (strip height for window)
borderColorKeyACCENT_BORDERColor name for the border
elevationDp0Shadow
fontSizeSp0Added to the normal text size
fontBoldfalseBold text
paddingDp-1Added to the normal padding (-1 means none)
textureTypenonenone, text, image, or gif
textureContentCharacters for text (use \n for multi-line tiles), or an image reference such as plugin:import:<id>:<texture id>
textureSizeDp0Tile or image size (0 is automatic)
textureColorKeyACCENTA color name, or a fixed #RRGGBB
textureColorModemaskmask, tint, or none for the image's own colors
textureOpacity0.250 to 1
textureBackgroundColorKey#000000Backdrop color behind the texture
textureBackgroundOpacity0Backdrop opacity, 0 to 1 (0 is off)
textureTileModegridgrid or single
textureFitModenonenone, horizontal or vertical
textureAnchorHorzcenterleft, center or right (single mode)
textureAnchorVertcentertop, center or bottom (single mode)
textureOffsetXDp, textureOffsetYDp0Offset from the anchor
textureMarginHorzDp, textureMarginVertDp0Spacing between grid tiles
texturePanDirDeg90Pan direction, 0 to 359
texturePanSpeedDpPerSec0Pan speed
textureRotateSpeedDegPerSec0Tile rotation, -180 to 180 (negative is counter-clockwise)
textureSingleLoopSec0Single mode loop length in seconds (0 is no loop)
textureGradientSyncfalseMove with the palette animation
textureFlipH, textureFlipVfalseMirror the texture

Delivery Screens

A Delivery Screen is an HTML page the app shows full screen over the lock screen when a rule's Delivery step runs. How to write the page itself is covered in Delivery Screen pages. This is Backdrop's entry, shortened:

"deliveryScreens": [
  {
    "id": "backdrop",
    "label": "Texture backdrop",
    "entry": "delivery/backdrop/screen.html",
    "assets": ["delivery/backdrop/texture.js"],
    "includesSound": true,
    "keepAwakeSeconds": 30,
    "params": [
      { "key": "image", "label": "Background", "type": "image", "default": "theme:screen" },
      { "key": "showTitle", "label": "Show the rule name", "type": "toggle", "default": true }
    ]
  }
]
FieldRequiredMeaning
idYesThe screen's id, unique within the package. It also names the screen's address (see the pages reference).
labelNoName in the Delivery step's screen list. Defaults to id.
entryYesPath to the screen's HTML file. The folder holding it is the screen's root: the page can load files from that folder and below, and nothing above it.
assetsNoEvery other file the screen uses, as paths. Hub installs download exactly these, so list them all.
includesSoundNotrue if the screen plays audio (see Sound). Without it the Delivery step hides its volume and stream controls. Default false.
keepAwakeSecondsNo0 to 30 (see Keeping the display on). Default 0. Above 0, the Delivery step shows a Keep the screen on switch, and the review dialog lists the time.
paramsNoSettings the Delivery step shows for this screen (below).
hashNoExpected hash of the entry file.

Delivery Screen params

Each entry in params becomes an input in the Delivery step's settings, and the page reads the chosen values at run time (see params for what it receives). Backdrop declares nine; its full list is a good reference.

{
  "key": "tileSize",
  "label": "Grid size",
  "type": "number",
  "min": 16, "max": 256, "step": 8,
  "default": 64,
  "hardMin": 1,
  "suffix": "dp",
  "showIf": { "fit": "grid" }
}
FieldApplies toMeaning
keyallRequired. A letter, then up to 39 letters, digits, or underscores. Unique within the screen.
labelallInput label. Defaults to key.
typeallRequired. One of the types below.
defaultallValue when the user hasn't set one, or has set an invalid one.
showIfallShow the input only while earlier params have certain values (below).
hinttext, tokensPlaceholder text in the field.
multilinetexttrue for a multi-line field.
optionschoiceRequired. Strings, or { "value", "label", "showIf" } objects.
min, maxnumberThe slider's ends. With both set (and max above min) the input is a slider, otherwise a number field.
stepnumberThe slider's step size.
hardMin, hardMaxnumberHard limits. Users can tap the slider value and type a number past min and max, but never past these.
suffixnumberUp to 8 characters shown after the value, such as % or dp.

Types:

TypeInputDefault when none is given
textText field""
tokensText field with the Token Builder""
numberA slider or number fieldmin, else 0
toggleCheckboxfalse
choiceDropdownThe first option
colorScreen default, Theme color, or Customnull
imageScreen default, Theme style, or Image from System, File, or Pluginnull
soundSystem, File, or Pluginnull
fontFile or Pluginnull

A number stays at or above 0 unless min or hardMin is negative.

Defaults for the special types:

  • A color default is #RRGGBB, #RRGGBBAA, or theme:<COLOR_NAME> (for example theme:ACCENT).
  • An image default can be theme:<element> (for example theme:screen) to use that style's texture from the step's theme.
  • An image default can be asset:textures/<file> to use one of the app's built-in textures, the same ones offered under System when picking an image (for example asset:textures/lemme.png).
  • An image, sound, or font default can be a path inside the screen's folder (images/bg.png) or one of the package's own declared files (_plugin/sounds/chime.ogg).

Up to 32 params are read. An entry with a bad or repeated key, an unknown type, or a choice without options is skipped without an error, so check the Delivery step dialog after installing.

showIf

showIf maps the keys of params declared earlier to the values they must have. Every key must match. A value matches one value, any value in a list, or none of them with not:

"showIf": { "fit": "grid" }
"showIf": { "fit": ["grid", "fit"] }
"showIf": { "image": { "not": "none" } }

Keys that don't name an earlier param are ignored. What each type compares:

TypeMatches against
text, tokens, number, toggle, choiceThe value itself
imagenone, theme (a theme style) or image (a picked file)
sound, fontnone or file
colornone, theme, or custom

A param left at its default matches as its default. A param is also hidden while any param its showIf names is hidden. Hiding an input doesn't change what the page receives (see params).

Choice options in object form can carry their own showIf. An option is offered only while its condition holds. If the selected option stops being offered, the choice moves to the default (when that is offered) or to the first offered option, both in the step dialog and when the alert fires.

Hashes

Any file entry, and a Delivery Screen's entry, may carry a hash such as "sha256:<lowercase hex>". The part before the colon names the algorithm; without one, SHA-256 is assumed. Hashes are checked whenever a plugin is installed, from a hub or from a file. A missing file or a mismatch stops the install before the review dialog appears.

Installing and updating

When a user opens your package, LemmeKnow checks the rules above and shows the review dialog (see Reviewing before you install). Play on a Delivery Screen runs it with a sample alert (see payload), so make sure your screen looks right with it.

To ship an update, change the files, bump version, and keep the same id. Installing replaces the old package completely, so include every file in each version. What the user sees when updating is described in Updating a plugin.

Hub plugins

A LemmeSee hub plugin can ship exactly the same contributes content alongside its own pages and scripts, installed from the hub with the same review dialog. See Installing on the phone in the hub guide.