add venbind. currently only linux x64 on x11

This commit is contained in:
Tuxinal 2024-08-18 19:27:25 +03:30
parent d99adcc951
commit f0919833e6
6 changed files with 82 additions and 19 deletions

View file

@ -25,7 +25,8 @@
}, },
"dependencies": { "dependencies": {
"arrpc": "github:OpenAsar/arrpc#c62ec6a04c8d870530aa6944257fe745f6c59a24", "arrpc": "github:OpenAsar/arrpc#c62ec6a04c8d870530aa6944257fe745f6c59a24",
"electron-updater": "^6.2.1" "electron-updater": "^6.2.1",
"venbind": "^0.0.2"
}, },
"optionalDependencies": { "optionalDependencies": {
"@vencord/venmic": "^6.1.0" "@vencord/venmic": "^6.1.0"

View file

@ -19,6 +19,9 @@ importers:
electron-updater: electron-updater:
specifier: ^6.2.1 specifier: ^6.2.1
version: 6.2.1 version: 6.2.1
venbind:
specifier: ^0.0.2
version: 0.0.2
optionalDependencies: optionalDependencies:
'@vencord/venmic': '@vencord/venmic':
specifier: ^6.1.0 specifier: ^6.1.0
@ -2784,6 +2787,9 @@ packages:
util-deprecate@1.0.2: util-deprecate@1.0.2:
resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==}
venbind@0.0.2:
resolution: {integrity: sha512-TlkghnnV43lmINTMOuZWvgRIIZJ3I5oNykXbGZPC22GE7gdoen9uPBWWEKLtN7BG4wjtT/dIAv2Xz9gHz9P4Gw==}
verror@1.10.1: verror@1.10.1:
resolution: {integrity: sha512-veufcmxri4e3XSrT0xwfUR7kguIkaxBeosDg00yDWhk49wdwkSUrvvsm7nc75e1PUyvIeZj6nS8VQRYz2/S4Xg==} resolution: {integrity: sha512-veufcmxri4e3XSrT0xwfUR7kguIkaxBeosDg00yDWhk49wdwkSUrvvsm7nc75e1PUyvIeZj6nS8VQRYz2/S4Xg==}
engines: {node: '>=0.6.0'} engines: {node: '>=0.6.0'}
@ -3441,7 +3447,7 @@ snapshots:
app-builder-bin@5.0.0-alpha.6: {} app-builder-bin@5.0.0-alpha.6: {}
app-builder-lib@24.13.3(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)): app-builder-lib@24.13.3(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)):
dependencies: dependencies:
'@develar/schema-utils': 2.6.5 '@develar/schema-utils': 2.6.5
'@electron/notarize': 2.2.1 '@electron/notarize': 2.2.1
@ -3455,7 +3461,7 @@ snapshots:
builder-util-runtime: 9.2.4 builder-util-runtime: 9.2.4
chromium-pickle-js: 0.2.0 chromium-pickle-js: 0.2.0
debug: 4.3.5 debug: 4.3.5
dmg-builder: 25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)) dmg-builder: 25.0.1(electron-builder-squirrel-windows@24.13.3)
ejs: 3.1.10 ejs: 3.1.10
electron-builder-squirrel-windows: 24.13.3(dmg-builder@25.0.1) electron-builder-squirrel-windows: 24.13.3(dmg-builder@25.0.1)
electron-publish: 24.13.1 electron-publish: 24.13.1
@ -3475,7 +3481,7 @@ snapshots:
transitivePeerDependencies: transitivePeerDependencies:
- supports-color - supports-color
app-builder-lib@25.0.1(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)): app-builder-lib@25.0.1(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)):
dependencies: dependencies:
'@develar/schema-utils': 2.6.5 '@develar/schema-utils': 2.6.5
'@electron/notarize': 2.3.2 '@electron/notarize': 2.3.2
@ -3490,7 +3496,7 @@ snapshots:
builder-util-runtime: 9.2.5 builder-util-runtime: 9.2.5
chromium-pickle-js: 0.2.0 chromium-pickle-js: 0.2.0
debug: 4.3.5 debug: 4.3.5
dmg-builder: 25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)) dmg-builder: 25.0.1(electron-builder-squirrel-windows@24.13.3)
ejs: 3.1.10 ejs: 3.1.10
electron-builder-squirrel-windows: 24.13.3(dmg-builder@25.0.1) electron-builder-squirrel-windows: 24.13.3(dmg-builder@25.0.1)
electron-publish: 25.0.1 electron-publish: 25.0.1
@ -4051,9 +4057,9 @@ snapshots:
'@types/react': 17.0.2 '@types/react': 17.0.2
moment: 2.30.1 moment: 2.30.1
dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)): dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3):
dependencies: dependencies:
app-builder-lib: 25.0.1(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)) app-builder-lib: 25.0.1(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1))
builder-util: 25.0.1 builder-util: 25.0.1
builder-util-runtime: 9.2.5 builder-util-runtime: 9.2.5
fs-extra: 10.1.0 fs-extra: 10.1.0
@ -4104,7 +4110,7 @@ snapshots:
electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1): electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1):
dependencies: dependencies:
app-builder-lib: 24.13.3(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)) app-builder-lib: 24.13.3(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1))
archiver: 5.3.2 archiver: 5.3.2
builder-util: 24.13.1 builder-util: 24.13.1
fs-extra: 10.1.0 fs-extra: 10.1.0
@ -4114,11 +4120,11 @@ snapshots:
electron-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)): electron-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)):
dependencies: dependencies:
app-builder-lib: 25.0.1(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)) app-builder-lib: 25.0.1(dmg-builder@25.0.1(electron-builder-squirrel-windows@24.13.3))(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1))
builder-util: 25.0.1 builder-util: 25.0.1
builder-util-runtime: 9.2.5 builder-util-runtime: 9.2.5
chalk: 4.1.2 chalk: 4.1.2
dmg-builder: 25.0.1(electron-builder-squirrel-windows@24.13.3(dmg-builder@25.0.1)) dmg-builder: 25.0.1(electron-builder-squirrel-windows@24.13.3)
fs-extra: 10.1.0 fs-extra: 10.1.0
is-ci: 3.0.1 is-ci: 3.0.1
lazy-val: 1.0.5 lazy-val: 1.0.5
@ -5983,6 +5989,8 @@ snapshots:
util-deprecate@1.0.2: {} util-deprecate@1.0.2: {}
venbind@0.0.2: {}
verror@1.10.1: verror@1.10.1:
dependencies: dependencies:
assert-plus: 1.0.0 assert-plus: 1.0.0

View file

@ -45,6 +45,10 @@ async function copyVenmic() {
copyFile( copyFile(
"./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node", "./node_modules/@vencord/venmic/prebuilds/venmic-addon-linux-arm64/node-napi-v7.node",
"./static/dist/venmic-arm64.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")); ]).catch(() => console.warn("Failed to copy venmic. Building without venmic support"));
} }

View file

@ -16,6 +16,7 @@ import { registerMediaPermissionsHandler } from "./mediaPermissions";
import { registerScreenShareHandler } from "./screenShare"; import { registerScreenShareHandler } from "./screenShare";
import { Settings, State } from "./settings"; import { Settings, State } from "./settings";
import { isDeckGameMode } from "./utils/steamOS"; import { isDeckGameMode } from "./utils/steamOS";
import { startVenbind } from "./venbind";
if (IS_DEV) { if (IS_DEV) {
require("source-map-support").install(); require("source-map-support").install();
@ -88,6 +89,7 @@ function init() {
app.whenReady().then(async () => { app.whenReady().then(async () => {
if (process.platform === "win32") app.setAppUserModelId("dev.vencord.vesktop"); if (process.platform === "win32") app.setAppUserModelId("dev.vencord.vesktop");
startVenbind();
registerScreenShareHandler(); registerScreenShareHandler();
registerMediaPermissionsHandler(); registerMediaPermissionsHandler();

View file

@ -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() { function readCss() {
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => ""); return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
} }

57
src/main/venbind.ts Normal file
View 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);
});