Skip to content

Latest commit

 

History

History
278 lines (208 loc) · 8.45 KB

configuration.md

File metadata and controls

278 lines (208 loc) · 8.45 KB

Configuration

Table of contents

Files

Krabby’s default configuration is located in ~/.config/krabby/packages/krabby.

Mapping

~/.config/krabby/config.js

const { modes } = krabby
const { modal } = modes

modal.map('Command', ['F2'], (event) => console.log(krabby.settings), 'Display settings in the console', 'Help')

You are encouraged to read the default configuration.

See modal.js for a complete reference and src/krabby for examples of mappings.

Keyboard layout

Use the home row and display keys with the US layout:

~/.config/krabby/config.js

const { modes } = krabby
const { modal } = modes

modal.keyMap = {
  Backquote: { key: '`', shiftKey: '~' }, Digit1: { key: '1', shiftKey: '!' }, Digit2: { key: '2', shiftKey: '@' }, Digit3: { key: '3', shiftKey: '#' }, Digit4: { key: '4', shiftKey: '$' }, Digit5: { key: '5', shiftKey: '%' }, Digit6: { key: '6', shiftKey: '^' }, Digit7: { key: '7', shiftKey: '&' }, Digit8: { key: '8', shiftKey: '*' }, Digit9: { key: '9', shiftKey: '(' }, Digit0: { key: '0', shiftKey: ')' }, Minus: { key: '-', shiftKey: '_' }, Equal: { key: '=', shiftKey: '+' },
  KeyQ: { key: 'q', shiftKey: 'Q' }, KeyW: { key: 'w', shiftKey: 'W' }, KeyE: { key: 'e', shiftKey: 'E' }, KeyR: { key: 'r', shiftKey: 'R' }, KeyT: { key: 't', shiftKey: 'T' }, KeyY: { key: 'y', shiftKey: 'Y' }, KeyU: { key: 'u', shiftKey: 'U' }, KeyI: { key: 'i', shiftKey: 'I' }, KeyO: { key: 'o', shiftKey: 'O' }, KeyP: { key: 'p', shiftKey: 'P' }, BracketLeft: { key: '[', shiftKey: '{' }, BracketRight: { key: ']', shiftKey: '}' }, Backslash: { key: '\\', shiftKey: '|' },
  KeyA: { key: 'a', shiftKey: 'A' }, KeyS: { key: 's', shiftKey: 'S' }, KeyD: { key: 'd', shiftKey: 'D' }, KeyF: { key: 'f', shiftKey: 'F' }, KeyG: { key: 'g', shiftKey: 'G' }, KeyH: { key: 'h', shiftKey: 'H' }, KeyJ: { key: 'j', shiftKey: 'J' }, KeyK: { key: 'k', shiftKey: 'K' }, KeyL: { key: 'l', shiftKey: 'L' }, Semicolon: { key: ';', shiftKey: ':' }, Quote: { key: "'", shiftKey: '"' },
  KeyZ: { key: 'z', shiftKey: 'Z' }, KeyX: { key: 'x', shiftKey: 'X' }, KeyC: { key: 'c', shiftKey: 'C' }, KeyV: { key: 'v', shiftKey: 'V' }, KeyB: { key: 'b', shiftKey: 'B' }, KeyN: { key: 'n', shiftKey: 'N' }, KeyM: { key: 'm', shiftKey: 'M' }, Comma: { key: ',', shiftKey: '<' }, Period: { key: '.', shiftKey: '>' }, Slash: { key: '/', shiftKey: '?' }
}

Hint.KEY_MAP = () => ({
  Digit1: '1', Digit2: '2', Digit3: '3', Digit4: '4', Digit5: '5', Digit6: '6', Digit7: '7', Digit8: '8', Digit9: '9', Digit0: '0',
  KeyQ: 'q', KeyW: 'w', KeyE: 'e', KeyR: 'r', KeyT: 't', KeyY: 'y', KeyU: 'u', KeyI: 'i', KeyO: 'o', KeyP: 'p',
  KeyA: 'a', KeyS: 's', KeyD: 'd', KeyF: 'f', KeyG: 'g', KeyH: 'h', KeyJ: 'j', KeyK: 'k', KeyL: 'l',
  KeyZ: 'z', KeyX: 'x', KeyC: 'c', KeyV: 'v', KeyB: 'b', KeyN: 'n', KeyM: 'm'
})

Hint.keys = () => (
  ['KeyA', 'KeyJ', 'KeyS', 'KeyK', 'KeyD', 'KeyL', 'KeyG', 'KeyH', 'KeyE', 'KeyW', 'KeyO', 'KeyR', 'KeyU', 'KeyV', 'KeyN', 'KeyC', 'KeyM']
)

See modal.js and hint.js for a complete reference.

Hint appearance

~/.config/krabby/config.js

const { settings } = krabby

settings['hint-style'] = {
  textColor: 'royalblue',
  activeCharacterTextColor: 'lightsteelblue',
  backgroundColorStart: 'white',
  backgroundColorEnd: 'ghostwhite',
  borderColor: 'ghostwhite'
}

See hint.js for a complete reference.

Tab search

Change the dmenu command to search with fzf and Alacritty:

~/.local/bin/dmenu

#!/bin/sh

# A drop-in dmenu replacement using fzf with Alacritty.

# – fzf (https://github.com/junegunn/fzf)
# – Alacritty (https://github.com/alacritty/alacritty)

# Create IO files
state=$(mktemp -d)
input=$state/input
output=$state/output
trap 'rm -Rf "$state"' EXIT

# Get input
cat > "$input"

# Run fzf with Alacritty
alacritty --class 'popup' --command sh -c 'fzf < "$1" > "$2"' -- "$input" "$output"

# Write output
cat "$output"

# Exit code
if test ! -s "$output"; then
  exit 1
fi

See webextension-dmenu for a complete reference.

External editor

Open Kakoune in Alacritty:

~/.config/krabby/config.js

const { extensions } = krabby
const { editor } = extensions

editor.send('set', {
  editor: `
    alacritty --class 'popup' --command \\
      kak "$file" -e "
        select $anchor_line.$anchor_column,$cursor_line.$cursor_column
      "
  `
})

See webextension-editor for a complete reference.

mpv

~/.config/krabby/config.js

const { settings } = krabby

settings['mpv-config'] = ['-no-config', '-no-terminal']

settings['mpv-environment'] = {
  MPV_HOME: '~/.mpv'
}

HTML filter

~/.config/krabby/config.js

const { settings } = krabby

settings['html-filter'] = ['pandoc', '--from', 'html', '--to', 'asciidoc']

Plumbing

Change the dmenu command:

export DMENU=dmenu

Change the clipboard copy and paste commands:

export CLIPBOARD_COPY=wl-copy
export CLIPBOARD_PASTE=wl-paste

See the plumb script for a complete reference.

Show keys

~/.config/krabby/config.js

const { extensions, modes } = krabby
const { commands } = extensions
const { modal } = modes

// Show keys for screencasts
const showKeys = () => {
  modal.on('command', ({ keyChord, description, label }) => {
    const keys = modal.keyValues(keyChord)
    const key = keys.join('-')
    commands.send('notify', 'show-keys', {
      title: label,
      message: `${key}${description}`
    })
  })
  // Show native commands
  modal.on('default', ({ metaKey, altKey, ctrlKey, shiftKey, code }) => {
    const keyChord = { metaKey, altKey, ctrlKey, shiftKey, code }
    const keys = modal.keyValues(keyChord)
    const key = keys.join('-')
    commands.send('notify', 'show-keys', {
      title: 'Native',
      message: key
    })
  })
}

// Enable show-keys notifications
// showKeys()