diff --git a/src/main/ipc.ts b/src/main/ipc.ts
index 504bd10..1e3cca4 100644
--- a/src/main/ipc.ts
+++ b/src/main/ipc.ts
@@ -7,7 +7,7 @@
if (process.platform === "linux") import("./virtmic");
import { execFile } from "child_process";
-import { app, BrowserWindow, dialog, RelaunchOptions, session, shell } from "electron";
+import { app, BrowserWindow, clipboard, dialog, nativeImage, RelaunchOptions, session, shell } from "electron";
import { mkdirSync, readFileSync, watch } from "fs";
import { open, readFile } from "fs/promises";
import { release } from "os";
@@ -120,6 +120,13 @@ handle(IpcEvents.SELECT_VENCORD_DIR, async () => {
handle(IpcEvents.SET_BADGE_COUNT, (_, count: number) => setBadgeCount(count));
+handle(IpcEvents.CLIPBOARD_COPY_IMAGE, async (_, buf: ArrayBuffer, src: string) => {
+ clipboard.write({
+ html: ``,
+ image: nativeImage.createFromBuffer(Buffer.from(buf))
+ });
+});
+
function readCss() {
return readFile(VENCORD_QUICKCSS_FILE, "utf-8").catch(() => "");
}
diff --git a/src/preload/VesktopNative.ts b/src/preload/VesktopNative.ts
index d72329d..d17bd23 100644
--- a/src/preload/VesktopNative.ts
+++ b/src/preload/VesktopNative.ts
@@ -71,5 +71,9 @@ export const VesktopNative = {
onActivity(cb: (data: string) => void) {
ipcRenderer.on(IpcEvents.ARRPC_ACTIVITY, (_, data: string) => cb(data));
}
+ },
+ clipboard: {
+ copyImage: (imageBuffer: Uint8Array, imageSrc: string) =>
+ invoke(IpcEvents.CLIPBOARD_COPY_IMAGE, imageBuffer, imageSrc)
}
};
diff --git a/src/shared/IpcEvents.ts b/src/shared/IpcEvents.ts
index bd857c4..df64403 100644
--- a/src/shared/IpcEvents.ts
+++ b/src/shared/IpcEvents.ts
@@ -47,5 +47,7 @@ export const enum IpcEvents {
VIRT_MIC_START_SYSTEM = "VCD_VIRT_MIC_START_ALL",
VIRT_MIC_STOP = "VCD_VIRT_MIC_STOP",
- ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY"
+ ARRPC_ACTIVITY = "VCD_ARRPC_ACTIVITY",
+
+ CLIPBOARD_COPY_IMAGE = "VCD_CLIPBOARD_COPY_IMAGE"
}