Added ability to toggle voice using proc signals

This commit is contained in:
Oleh Polisan 2024-05-18 00:41:36 +03:00
parent a8d72fa665
commit 29c12dc034
5 changed files with 40 additions and 1 deletions

19
src/main/keybinds.ts Normal file
View file

@ -0,0 +1,19 @@
/*
* 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 { IpcEvents } from "shared/IpcEvents";
import { mainWin } from "./mainWindow";
export function initKeybinds() {
process.on("SIGPIPE", async () => {
mainWin.webContents.send(IpcEvents.TOGGLE_SELF_MUTE);
});
process.on("SIGUSR2", () => {
mainWin.webContents.send(IpcEvents.TOGGLE_SELF_DEAF);
});
}

View file

@ -35,6 +35,7 @@ import {
MIN_WIDTH,
VENCORD_FILES_DIR
} from "./constants";
import { initKeybinds } from "./keybinds";
import { Settings, State, VencordSettings } from "./settings";
import { createSplashWindow } from "./splash";
import { makeLinksOpenExternally } from "./utils/makeLinksOpenExternally";
@ -481,4 +482,5 @@ export async function createWindows() {
});
initArRPC();
initKeybinds();
}

View file

@ -78,5 +78,13 @@ export const VesktopNative = {
clipboard: {
copyImage: (imageBuffer: Uint8Array, imageSrc: string) =>
invoke<void>(IpcEvents.CLIPBOARD_COPY_IMAGE, imageBuffer, imageSrc)
},
voice: {
onToggleSelfMute: (listener: (...args: any[]) => void) => {
ipcRenderer.on(IpcEvents.TOGGLE_SELF_MUTE, listener);
},
onToggleSelfDeaf: (listener: (...args: any[]) => void) => {
ipcRenderer.on(IpcEvents.TOGGLE_SELF_DEAF, listener);
}
}
};

View file

@ -57,3 +57,11 @@ VesktopNative.arrpc.onActivity(data => {
arRPC.handleEvent(new MessageEvent("message", { data }));
});
VesktopNative.voice.onToggleSelfMute(() => {
findByPropsLazy("toggleSelfMute").toggleSelfMute();
});
VesktopNative.voice.onToggleSelfDeaf(() => {
findByPropsLazy("toggleSelfDeaf").toggleSelfDeaf();
});

View file

@ -49,5 +49,7 @@ export const enum IpcEvents {
ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY",
CLIPBOARD_COPY_IMAGE = "VCD_CLIPBOARD_COPY_IMAGE"
CLIPBOARD_COPY_IMAGE = "VCD_CLIPBOARD_COPY_IMAGE",
TOGGLE_SELF_MUTE = "VCD_TOGGLE_SELF_MUTE",
TOGGLE_SELF_DEAF = "VCD_TOGGLE_SELF_DEAF"
}