See the following examples:
~/.config/krabby/config.js
const { extensions, modes, commands } = krabby
const { shell } = extensions
const { modal } = modes
// Ping-pong
commands.ping = () => {
shell.port.postMessage({
id: 'ping-pong',
command: 'echo',
arguments: ['Ping']
})
shell.port.onMessage.addListener((response) => {
switch (response.id) {
case 'ping-pong':
console.log(response.output, 'Pong')
break
}
})
}
// Mappings
modal.map('Command', ['F2'], () => commands.ping(), 'Ping', 'Ping-pong')
See webextension-shell for a complete reference.