How to prevent Screen Share popup to appear when taking a screenshot on Linux?

19 Views Asked by At

I am using Electron to create a project managemnet tool. Basically, what it does is capture screenshots every 10 minutes. I have implemented a code which is taking screenshots correctly on Windows, but on Linux a popup appears asking to choose a display:

Popup

My code:

//ss-logic

ipcMain.on("capture-screenshot", async (event) => {
  const screenShotInfo = await captureScreen();

  const dataURL = screenShotInfo.toDataURL();
  event.sender.send("screenshot-captured", dataURL);
});

async function captureScreen() {
  const primaryDisplay = screen.getPrimaryDisplay();
  const options = {
    types: ["screen"],
    thumbnailSize: {
      width: primaryDisplay.size.width,
      height: primaryDisplay.size.height,
    },
    screen: {
      id: primaryDisplay.id,
    },
  };

  const sources = await desktopCapturer.getSources(options);

  const image = sources[0].thumbnail;
  return image;
}

How can I solve this?

0

There are 0 best solutions below