Add keyup/keydown support for the cli

TEMPORARY: show keybind ID in the keybind page
This commit is contained in:
Tuxinal 2024-05-11 19:53:43 +03:30
parent f08af9446f
commit 9748a036b6
3 changed files with 15 additions and 4 deletions

View file

@ -63,7 +63,13 @@ function init() {
const keybindIndex = cmdLine.indexOf("--keybind");
if (keybindIndex !== -1) {
if (cmdLine[keybindIndex + 2] === "keyup" || cmdLine[keybindIndex + 2] === "keydown") {
mainWin.webContents.executeJavaScript(
`Vesktop.keybindCallbacks[${cmdLine[keybindIndex + 1]}](${cmdLine[keybindIndex + 2] === "keydown" ? "true" : "false"})`
);
} else {
mainWin.webContents.executeJavaScript(`Vesktop.keybindCallbacks[${cmdLine[keybindIndex + 1]}](false)`);
}
} else if (data.IS_DEV) app.quit();
else if (mainWin) {
if (mainWin.isMinimized()) mainWin.restore();

View file

@ -134,7 +134,6 @@ const registered_keybinds = {};
handle(IpcEvents.KEYBIND_REGISTER, (_, id: number, shortcut: string, options: any) => {
registered_keybinds[id] = shortcut;
console.log(registered_keybinds);
});
handle(IpcEvents.KEYBIND_UNREGISTER, (_, id: number) => {
delete registered_keybinds[id];

View file

@ -22,8 +22,14 @@ addPatch({
},
{
// eslint-disable-next-line no-useless-escape
match: /\(0,\i.isDesktop\)\(\)/g,
match: /\(0,\i\.isDesktop\)\(\)/g,
replace: "true"
},
{
// THIS PATCH IS TEMPORARY
// eslint-disable-next-line no-useless-escape
match: /\.keybindGroup,\i.card\),children:\[/g,
replace: "$&`ID: ${this.props.keybind.id}`,"
}
]
},
@ -37,7 +43,7 @@ addPatch({
},
{
// eslint-disable-next-line no-useless-escape
match: /inputEventUnregister\((parseInt\(\i,10\))\);else\{/,
match: /inputEventUnregister\((parseInt\(\i,10\))\);else if\(\i\[\i\]\)\{/,
replace: "$&$self.unregisterKeybind($1);return;"
}
]