-
-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add venbind. currently only linux x64
- Loading branch information
Showing
6 changed files
with
82 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* SPDX-License-Identifier: GPL-3.0 | ||
* Vesktop, a desktop app aiming to give you a snappier Discord Experience | ||
* Copyright (c) 2023 Vendicated and Vencord contributors | ||
*/ | ||
|
||
import { join } from "path"; | ||
import { IpcEvents } from "shared/IpcEvents"; | ||
import { STATIC_DIR } from "shared/paths"; | ||
import type { Venbind as VenbindType } from "venbind"; | ||
|
||
import { mainWin } from "./mainWindow"; | ||
import { handle } from "./utils/ipcWrappers"; | ||
|
||
let venbind: VenbindType | null = null; | ||
export function obtainVenbind() { | ||
// TODO?: make binary outputs consistant with node's apis | ||
let os: string; | ||
switch (process.platform) { | ||
case "linux": | ||
os = "linux"; | ||
break; | ||
// case "win32": | ||
// os = "windows"; | ||
// case "darwin": | ||
// os = "darwin"; | ||
default: | ||
return null; | ||
}; | ||
let arch: string; | ||
switch (process.arch) { | ||
case "x64": | ||
arch = "x86_64"; | ||
break; | ||
// case "arm64": | ||
// arch = "aarch64"; | ||
// break; | ||
default: | ||
return null; | ||
}; | ||
if (venbind == null) venbind = require(join(STATIC_DIR, `dist/venbind-${os}-${arch}.node`)); | ||
return venbind; | ||
} | ||
|
||
export function startVenbind() { | ||
const venbind = obtainVenbind(); | ||
venbind?.startKeybinds(null, x => { | ||
mainWin.webContents.executeJavaScript(`Vesktop.keybindCallbacks[${x}](false)`); | ||
}); | ||
} | ||
|
||
handle(IpcEvents.KEYBIND_REGISTER, (_, id: number, shortcut: string, options: any) => { | ||
obtainVenbind()?.registerKeybind(shortcut, id); | ||
}); | ||
handle(IpcEvents.KEYBIND_UNREGISTER, (_, id: number) => { | ||
obtainVenbind()?.unregisterKeybind(id); | ||
}); |