mirror of
https://github.com/Vencord/Vesktop.git
synced 2025-02-23 13:45:09 +00:00
add venbind. currently only linux x64 on x11
This commit is contained in:
parent
db542ce852
commit
239e30a53e
6 changed files with 8044 additions and 5910 deletions
|
@ -25,7 +25,8 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"arrpc": "github:OpenAsar/arrpc#5aadc307cb9bf4479f0a12364a253b07a77ace22",
|
||||
"electron-updater": "^6.3.9"
|
||||
"electron-updater": "^6.3.9",
|
||||
"venbind": "^0.0.2"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
"@vencord/venmic": "^6.1.0"
|
||||
|
|
13879
pnpm-lock.yaml
generated
13879
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
|
@ -45,6 +45,10 @@ async function copyVenmic() {
|
|||
copyFile(
|
||||
"./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node",
|
||||
"./static/dist/venmic-arm64.node"
|
||||
),
|
||||
copyFile(
|
||||
"./node_modules/venbind/prebuilds/linux-x86_64/venbind-linux-x86_64.node",
|
||||
"./static/dist/venbind-linux-x86_64.node"
|
||||
)
|
||||
]).catch(() => console.warn("Failed to copy venmic. Building without venmic support"));
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import { registerMediaPermissionsHandler } from "./mediaPermissions";
|
|||
import { registerScreenShareHandler } from "./screenShare";
|
||||
import { Settings, State } from "./settings";
|
||||
import { isDeckGameMode } from "./utils/steamOS";
|
||||
import { startVenbind } from "./venbind";
|
||||
|
||||
if (IS_DEV) {
|
||||
require("source-map-support").install();
|
||||
|
@ -91,6 +92,7 @@ function init() {
|
|||
app.whenReady().then(async () => {
|
||||
if (process.platform === "win32") app.setAppUserModelId("dev.vencord.vesktop");
|
||||
|
||||
startVenbind();
|
||||
registerScreenShareHandler();
|
||||
registerMediaPermissionsHandler();
|
||||
|
||||
|
|
|
@ -135,15 +135,6 @@ handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string)
|
|||
});
|
||||
});
|
||||
|
||||
const registered_keybinds = {};
|
||||
|
||||
handle(IpcEvents.KEYBIND_REGISTER, (_, id: number, shortcut: string, options: any) => {
|
||||
registered_keybinds[id] = shortcut;
|
||||
});
|
||||
handle(IpcEvents.KEYBIND_UNREGISTER, (_, id: number) => {
|
||||
delete registered_keybinds[id];
|
||||
});
|
||||
|
||||
function readCss() {
|
||||
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
|
||||
}
|
||||
|
|
57
src/main/venbind.ts
Normal file
57
src/main/venbind.ts
Normal file
|
@ -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);
|
||||
});
|
Loading…
Add table
Reference in a new issue