-
Notifications
You must be signed in to change notification settings - Fork 8
Automation adb and Tasker
WM Keyboard accepts commands from other apps as broadcast intents. Send them
from a computer with adb, or from an automation app such as Tasker,
MacroDroid or Automate. Put French on when you open one app, switch to a dark
theme at night, mute the key sound in a meeting, or show the keyboard from a
home-screen shortcut.
Privacy / Let other apps control the keyboard
Nothing works until you turn on Let other apps control the keyboard. It is off on a fresh install, and while it is off the keyboard ignores every command in this page, layout switching included.
When it is on, an Allowed actions row appears under it. That screen has one switch for each kind of command, in two groups:
Privacy / Allowed actions
| Row | Group | Default | Commands |
|---|---|---|---|
| Switch language and layout | Keyboard controls | On |
SET_LAYOUT, SET_LANGUAGE, NEXT_LAYOUT, PREVIOUS_LAYOUT, LIST_LAYOUTS
|
| Apply a keyboard mode | Keyboard controls | On | SET_MODE |
| Change the theme | Keyboard controls | On | SET_THEME |
| Show and pin the keyboard | Keyboard controls | On |
SHOW_KEYBOARD, SET_PINNED
|
| Sound and haptics | Keyboard controls | On |
SET_KEY_SOUND, SET_HAPTICS
|
| Power saving and data saver | Keyboard controls | On |
SET_POWER_SAVING, SET_DATA_SAVER
|
| Size and position | Keyboard controls | On | SET_POSITION |
| Open a tool | Keyboard controls | On | OPEN_TOOL |
| Turn incognito on | Keyboard controls | On |
SET_INCOGNITO with enabled true |
| Turn incognito off | Needs more trust | Off |
SET_INCOGNITO with enabled false |
| Add and block words | Needs more trust | Off |
ADD_WORD, BLOCK_WORD
|
| Back up now | Needs more trust | Off | BACKUP_NOW |
| Announce layout changes | Needs more trust | Off | The LAYOUT_CHANGED event the keyboard sends |
| Type text | Needs more trust | Off | TYPE_TEXT |
The Keyboard controls each do what a control on the keyboard does, and you can undo them. The Needs more trust rows change what the keyboard knows, type into other apps, or tell other apps what you do, so each one stays off until you turn it on by name. Turn one on only for an automation you set up yourself.
A command whose row is off is refused, and the answer says which row to turn on. The switches take effect on the next command, with nothing to restart.
Every command is a broadcast to the package com.wasimaster.wmkeyboard, with
an action that starts com.wasimaster.wmkeyboard.action.. Name the package
with -p: Android 8 and newer do not deliver a broadcast to an app that the
sender doesn't name.
adb shell am broadcast -a com.wasimaster.wmkeyboard.action.SET_LANGUAGE -p com.wasimaster.wmkeyboard --es language fr
adb shell am broadcast -a com.wasimaster.wmkeyboard.action.SET_THEME -p com.wasimaster.wmkeyboard --es theme default
adb shell am broadcast -a com.wasimaster.wmkeyboard.action.SET_KEY_SOUND -p com.wasimaster.wmkeyboard --ez enabled falseam broadcast prints the keyboard's answer. A command that worked reads
result=-1 and says what it did:
Broadcast completed: result=-1, data="builtin_french"
A command the keyboard can't carry out reads result=0 and says why, for
example no enabled layout is for the language "de" or
not allowed: turn on "theme" under Settings › Privacy › Allowed actions.
Tasker, MacroDroid and Automate each have an action that sends an intent. The fields are the same in each. In Tasker:
- Add the action System › Send Intent.
- Set Action to
com.wasimaster.wmkeyboard.action.SET_LANGUAGE. - Set Extra to
language:fr. - Set Package to
com.wasimaster.wmkeyboard. - Set Target to Broadcast Receiver.
Put the action in a task that an App profile starts, and the keyboard
changes language as that app opens. An automation app does not read the answer
the way adb does, so test a new command from adb first.
All extras are strings unless the table says otherwise. The on/off commands
take enabled as a boolean (--ez enabled true) or as text (true, false,
on, off, 1, 0), which is what Tasker sends. Leave enabled out and the
command flips the current state.
| Action | Extras | Does | Needs the keyboard running |
|---|---|---|---|
SET_LAYOUT |
layout: layout id or name |
Switches to that layout. | No |
SET_LANGUAGE |
language: language id, locale or name |
Switches to a layout of that language. | No |
NEXT_LAYOUT |
none | One layout forward in your switch order. | No |
PREVIOUS_LAYOUT |
none | One layout back. | No |
LIST_LAYOUTS |
none | Changes nothing. Answers with the layouts you have on. | No |
SET_MODE |
mode: mode id or name, or auto
|
Applies a keyboard mode, as the Modes tool does. auto goes back to automatic. |
Yes |
SET_THEME |
theme: theme id or name, or default
|
Picks the keyboard theme. | No |
SHOW_KEYBOARD |
none | Brings the keyboard up over the field in use. | Yes |
SET_PINNED |
enabled |
Keeps the keyboard on screen, or stops. | No |
SET_KEY_SOUND |
enabled |
Key sound on or off. | No |
SET_HAPTICS |
enabled |
Vibration on key press on or off. | No |
SET_POWER_SAVING |
enabled |
Power saving's manual switch. | No |
SET_DATA_SAVER |
enabled |
Data saver's manual switch. | No |
SET_POSITION |
position: normal, left, right, split or floating
|
Puts the keyboard in that shape. Each one turns the others off. | No |
OPEN_TOOL |
tool: a tool name such as TRANSLATE or EMOJI
|
Opens that tool's panel. | Yes |
SET_INCOGNITO |
enabled |
Incognito on or off. | No |
ADD_WORD |
word |
Adds one word to your personal dictionary, as adding it by hand does. | Yes |
BLOCK_WORD |
word, and language if the block is for one language only |
Stops the word being suggested. | No |
BACKUP_NOW |
none | Starts a backup to every location ticked under Back up to in Automatic backup. Fails when none is ticked. | No |
TYPE_TEXT |
text, or snippet: a snippet's trigger or label |
Types into the field in use. | Yes |
"Needs the keyboard running" means WM Keyboard is the keyboard you have selected. The other commands also work while a different keyboard is selected: they change the setting, and WM Keyboard opens with it next time.
-
SET_LAYOUTtakes the layout's id, such asbuiltin_qwerty. Case does not matter. It also takes the layout's name, such asAZERTY, but only when exactly one of your layouts has that name. When two share it, the command is refused, not guessed. Only layouts you turned on can be chosen. -
SET_LANGUAGEtakes a language id (en,bn,bn_rom), a locale (en-US,bn_BD), or the language's name in English or in the language itself (French,Français). A locale the keyboard has no exact match for falls back to its first part, sofr-CAfinds French. When you have several layouts of the language on, the one you used last wins. When a layout of it is already in use, nothing changes. -
NEXT_LAYOUTandPREVIOUS_LAYOUTwalk your switch order and wrap around at either end. They always use the plain order, even with 🌐 goes back to the last language on, so an automation gets the same result every time. -
SET_MODEandSET_THEMEmatch an id first and then a name, and refuse a name that two modes or two themes share. A theme you made wins a name it shares with a built-in theme. A mode applied this way lasts like one picked from the Modes tool: until you change app, or until you change it, depending on your setting for that. -
SET_THEMEwhile the automatic light and dark pair is on saves the pick, but the pair still decides what you see. The answer says so. -
OPEN_TOOLopens only tools that have a panel. Tools that act at once, such as Paste, Select all, Undo or the flashlight, are refused, because opening a tool should not change your text or your phone. The tool name is the one on Deep links fortool/{toolName}, in any case. -
TYPE_TEXTtypes into the field that has the keyboard, never into a password field, and at most 10,000 characters at once. A snippet is found by its trigger first and its label second, and expands exactly as a tap on it in the Snippets panel does.
Send LIST_LAYOUTS to see what you can switch to:
adb shell am broadcast -a com.wasimaster.wmkeyboard.action.LIST_LAYOUTS -p com.wasimaster.wmkeyboardEach line holds a layout id, its language id and its name, separated by tabs,
in your switch order. A * marks the layout in use.
Broadcast completed: result=-1, data="* builtin_qwerty en QWERTY
builtin_avro bn Avro phonetic"
For modes and themes, the name on screen works. It must be the name exactly as you gave it, or for a built-in theme, its English name.
With Announce layout changes on, the keyboard sends a broadcast every time the layout on screen changes, whatever changed it:
| Action | Extras |
|---|---|
com.wasimaster.wmkeyboard.event.LAYOUT_CHANGED |
layout (id), language (language id), name (layout name) |
In Tasker, use the Intent Received event with that action. Tasker then has
%layout, %language and %name to work with. Any app on the phone that
listens gets the same broadcast, which is why the row is off by default: it
tells other apps which language you are typing in.
- The switch is a switch, not a password. Any app on the phone can send these commands. What stops one is your setting, not who sent it. Android has no permission that Tasker could hold and a stranger app could not.
- Nothing happens before the first unlock after a restart. Android keeps apps from receiving broadcasts until you unlock the phone once. From then on the commands work on the lock screen too.
- A layout switch is the same switch the 🌐 key makes. A half-typed word is committed first, the suggestions change language at once, and the layout goes on your recently-used list. With Remember language per app on, the app you are typing in remembers it too.
- A settings backup carries these switches. Restore one on a new phone and Let other apps control the keyboard comes back as it was.
-
To open a settings screen instead, use a
wmkeyboard://link. See Deep links & launcher shortcuts.
- Home
- Accessibility
- Addons
- Development
- Emoji
- Languages
- Plugins
- Privacy
-
Reference
- Gesture cheat sheet
- Typing
- Hardware shortcuts
- Automation: adb and Tasker
- Deep links & launcher shortcuts
- Key press
- Link builder
- Dictionaries & words
- File formats
- Languages
- Importing from other keyboards
- Appearance
- Importing from Espanso
- Keyboard themes
- Keyboard font
- Troubleshooting
- Glossary
- Icons
- Easter eggs
- Layout & size
- Key layouts
- Rows & bars
- Keyboard modes
- Emoji
- Phone number formats
- Tools
- Addons & plugins
- Reference - Accessibility
- Fingerprint lock
- Reference - Data saver
- Reference - Permissions
- Privacy
- Reference - Selection actions
- Servers
- Reference - Backup & restore
- About & diagnostics
- Statistics
- Settings A–Z
- Smart
- Start
- Themes
-
Tools
- Clipboard manager
- Voice typing
- Transcription server
- Offline voice (Whisper)
- Handwriting
- Scanner (OCR, QR, documents)
- Camera tool
- Translate
- Search, Wikipedia & dictionary
- Media controls
- AI chat
- AI tools
- Utility tools
- Snippets & text expansion
- Text editing & cursor tools
- Instruments
- Trackpad
- Calendar
- KDE Connect
- App launcher
- Learn from text
- Vocabulary
- Resize the keyboard
- The toolbar
- Typing