Skip to content

Commit e682d9f

Browse files
committed
Automatically select first source for desktop capture under Wayland
- Updated `setDisplayMediaRequestHandler` to detect `XDG_SESSION_TYPE=wayland` - Enabled `{ useSystemPicker: true }` for macOS 15+ native picker
1 parent bcde9af commit e682d9f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/electron-main.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Please see LICENSE files in the repository root for full details.
1010

1111
// Squirrel on windows starts the app with various flags as hooks to tell us when we've been installed/uninstalled etc.
1212
import "./squirrelhooks.js";
13-
import { app, BrowserWindow, Menu, autoUpdater, dialog, type Input, type Event, session, protocol } from "electron";
13+
import { app, BrowserWindow, Menu, autoUpdater, dialog, type Input, type Event, session, protocol, desktopCapturer } from "electron";
1414
// eslint-disable-next-line n/file-extension-in-import
1515
import * as Sentry from "@sentry/electron/main";
1616
import AutoLaunch from "auto-launch";
@@ -555,9 +555,15 @@ app.on("ready", async () => {
555555
webContentsHandler(global.mainWindow.webContents);
556556

557557
session.defaultSession.setDisplayMediaRequestHandler((_, callback) => {
558-
global.mainWindow?.webContents.send("openDesktopCapturerSourcePicker");
558+
if (process.env.XDG_SESSION_TYPE === "wayland") {
559+
desktopCapturer.getSources({ types: ['screen', 'window'] }).then((sources) => {
560+
callback({ video: sources[0] })
561+
});
562+
} else {
563+
global.mainWindow?.webContents.send("openDesktopCapturerSourcePicker");
564+
}
559565
setDisplayMediaCallback(callback);
560-
});
566+
}, { useSystemPicker: true }); // Use Mac OS 15+ native picker
561567

562568
setupMediaAuth(global.mainWindow);
563569
});

0 commit comments

Comments
 (0)