Skip to content

Latest commit

 

History

History
38 lines (30 loc) · 965 Bytes

interfacing.md

File metadata and controls

38 lines (30 loc) · 965 Bytes

Interfacing Krabby with external programs

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.