Skip to content

Commit

Permalink
Fix for wayland screenshare including system audio.
Browse files Browse the repository at this point in the history
  • Loading branch information
Herbie Hopkins committed Jan 19, 2024
1 parent 42f64e2 commit 109d10c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 8 additions & 14 deletions app/browser/tools/chromeApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ const disableAutogain = require('./disableAutogain');
// In new versions of electron, contextIsolation is set to true by default.
// We should explicitly set it to false when creating BrowserWindow

let _getDisplayMedia;

function init(config) {
window.addEventListener('DOMContentLoaded', () => {
if (process.env.XDG_SESSION_TYPE === 'wayland') {
ipcRenderer.once('get-screensizes-response', (event, screens) => {
customGetDisplayMediaWayland(screens);
});
ipcRenderer.send('get-screensizes-request');
_getDisplayMedia = MediaDevices.prototype.getDisplayMedia;
MediaDevices.prototype.getDisplayMedia = customGetDisplayMediaWayland;
} else {
MediaDevices.prototype.getDisplayMedia = customGetDisplayMediaX11;
}
Expand All @@ -21,17 +21,11 @@ function init(config) {
});
}

function customGetDisplayMediaWayland(screens) {
ipcRenderer.invoke('desktopCapturerGetSources', { types: ['window', 'screen'] }).then(async (sources) => {
if (sources.length === 0)
return;
async function customGetDisplayMediaWayland(...args) {
args[0].audio = false;
args[0].systemAudio = 'exclude';

const properties = {
id: sources[0].id,
screen: screens.find(s => s.default)
};
ipcRenderer.send('selected-source', properties);
});
return await _getDisplayMedia.apply(navigator.mediaDevices, args);
}

function customGetDisplayMediaX11() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "teams-for-linux",
"version": "1.4.4",
"version": "1.4.5",
"main": "app/index.js",
"description": "Unofficial client for Microsoft Teams for Linux",
"homepage": "https://github.com/IsmaelMartinez/teams-for-linux",
Expand Down

0 comments on commit 109d10c

Please sign in to comment.