WM Keyboard plugins
Plugins are small Python programs that add tools to the keyboard. Start here: learn, look things up, or get help.
A plugin is a small Python program that adds a tool to the keyboard. It draws a panel, reacts when the user presses things, and can type into the app the user is writing in. With the user’s say-so, it can also reach a website or the user’s AI model.
from wm import plugin, ui
state = plugin.state(count=0)
def add(): state.count += 1
def render(): with ui.column(): ui.title(f"Pressed {state.count} times") ui.button("Press me", on_click=add, primary=True)That is a whole plugin, apart from a short plugin.json. You can write one on
the phone or in the browser, with a live preview beside the code:
Getting started
Section titled “Getting started”Guides
Section titled “Guides”One topic a page, in plain words, with code you can run:
- Drawing the panel: layout, text, inputs, lists, pictures, colours.
- State and events: callbacks,
plugin.state, saving values. - Pages, timers and places: open and close, several pages, timers, tiles and keywords.
- The internet and AI:
http, API keys, the user’s own server,ai. - Working with text: the field, the clipboard, buttons over selected text.
- Showing files: previews, thumbnails and syntax colours for the file manager.
- Saving data and settings:
storage,secrets, a settings page, reminders. - Phone features: vibrate, speak, share, scan, sensors, location, files.
- Translating your plugin:
_()and a file per language. - Testing and debugging: the web editor’s tabs, the phone, automatic tests.
- Sharing your plugin: the
.wmpluginfile, updates, addon repositories.
Reference
Section titled “Reference”Plugins written for API 4 keep working. Their pages are the classic tutorial and the classic API reference.
What a plugin can do
Section titled “What a plugin can do”- Draw its own panel from the keyboard’s widgets, in the user’s theme.
- Put text into the app: through an Insert button the user presses, or by
typing with the
field.writepermission. - Add buttons to the bar over selected text, which turn the selection into something else.
- Open from the Plugins tool, its own tool in the toolbox or on the toolbar, a key, the floating box, or a
keyword like
@define rain. - Keep data on the phone, run timers while it is open, and have a settings page the app draws.
- Show file types in the keyboard’s file manager, draw their pictures in the grid, and colour the text of code and config files.
- With the user’s permission: reach the websites it lists, ask the user’s AI model, read the text being written when the user presses something in its panel, or read the clipboard.
Each permission is shown before install. The ones that can read the user’s things or send them away are off until the user turns them on.
What a plugin cannot do
Section titled “What a plugin cannot do”- See what you type. There is no key event API. A plugin cannot observe, change or delay a single keystroke going to your app.
- Read the text you are writing in by itself. Even with
field.readallowed, a plugin reads the field only while it answers something you did in its panel, and never a password field or incognito text. - Reach the internet without you.
networkis off until you allow it, and then reaches only the websites the plugin listed. Data saver stops it. - Reach Android. No file paths, no reflection, no other apps. Only the named
calls in the
wmpackage. - Run in the background. A plugin only runs while its panel or floating box is open. A reminder is a line of text the app shows; the plugin does not run for it.
Text still gets into a plugin: you type into its box, press the paste button inside it, or select text and press one of its buttons on the selection bar. Results come back out when you press Insert under a result, or in place of the selection. Every one of those is a deliberate press, on a control the keyboard drew.
Using your plugins
Section titled “Using your plugins”The Plugins tool lists every plugin that has a panel. Tap one to open it. The tool takes the whole keyboard, the toolbar’s rows included, and so does any plugin whose author made it tall, such as a planner or a form; the back arrow in the header returns to the keys. A plugin with tabs opens on the tab you left it on, and an author can give a plugin’s icon its own colour. Each row has more behind it:
- Hold a row, or tap its ⋮, for its options: Settings and permissions, Add to toolbar, Add to toolbox, and Turn off.
- Swipe a row toward the start for the two used most: the toolbar button and its settings page.
A plugin’s page in settings also lists, under Files, the file types it shows in the file manager (and whether it draws their pictures in the grid) and the ones whose text it colours.
The same list in settings works the same way, except that a hold there
starts picking and the ⋮ holds the options. Its options also include
Edit the code, Delete the stored data and Uninstall, and a swipe
shows the toolbar button, Turn on or Turn off, and Uninstall.
While picking, taps tick plugins, and the bar at the foot exports the ticked
ones into one zip of .wmplugin files (their code, assets and translations,
not their stored data) or uninstalls them all. Install from a file takes
that zip too: each plugin in it is checked, shows its own permissions and asks
before it goes in.
A plugin as a tool of its own
Section titled “A plugin as a tool of its own”Any plugin with a panel can have its own button, like the built-in tools. Tap the button and the plugin opens at once, without going through the Plugins list. Pick where it goes on the plugin’s page, under Show as a tool: Panel only, Toolbar or Toolbox, and Second toolbar while the second toolbar is on.
WM Keyboard Tools Plugins (a plugin) Show as a toolThese buttons are custom buttons of the plugin kind, so you can reorder or remove them there too. Uninstalling a plugin removes its button.
Lua plugins were retired
Section titled “Lua plugins were retired”Plugins were written in Lua until version 0.6.6, which replaced Lua with Python. When you update to 0.6.6, every Lua plugin on the phone is removed, since nothing is left to run it. The keyboard’s plugin list and the Plugins screen say which ones went.
What each one saved is kept. Install a Python plugin with the same id and its
data comes back as it was. The five demo plugins in the addon repository (Cipher Tool, UI Kitchen Sink, Todo List, Text Tools and Math Mode) kept their ids in the move, so
installing the Python Todo List brings your list back. Only what a plugin
saved with wm.storage is kept; its log and any reminders it had set are not.
Data that no plugin has claimed is listed on the Plugins screen, each with a button to delete it now. Anything still unclaimed 90 days after the update is deleted on its own.
WM Keyboard Tools Plugins Manage pluginsA Lua plugin file opened after the update is refused with a reason that says it was written in Lua; Lua is refused has the exact rule.
