-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkeymaps.js
40 lines (33 loc) · 1.03 KB
/
keymaps.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import { ProcessSync } from "../qjs-ext-lib/src/process.js";
import Fzf from "../justjs/fzf.js";
import { getKeyBinds, handleFzfExec, setCommonFzfArgs } from "./utils.js";
export default async function KeyMaps() {
const keyMaps = getKeyBinds()
.map(([mode, _, keyBind]) => [keyBind, mode]);
keyMaps.push(
["tab", "Switch to next mode"],
["shift-tab", "Switch to next UI preset"],
[
`${USER_ARGUMENTS.modKey}-space`,
"Refresh application list for launcher.",
],
);
const maxKeymapLength = keyMaps.reduce(
(length, [keyMap]) => length > keyMap.length ? length : keyMap.length,
0,
);
const keyMapsStr = keyMaps.map(([keyBind, mode]) =>
`${keyBind.padEnd(maxKeymapLength)} : ${mode}`
).join("\0");
const fzfArgs = new Fzf().prompt("'Keybinds: '").read0().noInfo()
.marker("''").pointer("''");
setCommonFzfArgs(fzfArgs);
const fzfKeymaps = new ProcessSync(
fzfArgs.toArray(),
{
input: keyMapsStr,
useShell: true,
},
);
await handleFzfExec(fzfKeymaps);
}