linux - How to exclude specific Electron windows from being recorded by my app's screen recording on Fedora? - Stack Ove

admin2025-04-21  1

I am building an Electron application on Fedora that includes a screen recording feature. While recording the screen, I want to exclude specific Electron windows (created by my app) from being captured in the recording.

My application uses Electron's desktopCapturer module to record the screen, and I'm looking for a way to prevent specific windows from being recorded (e.g., tool bar).

OS: Fedora 41 Desktop Environment: GNOME Electron Version: 31.0.2

I’ve explored the following options:

Electron's setContentProtection(true): This works on windows, but not on linux.

 mainWindow = new BrowserWindow({
    width: 350,
    height: 400,
    minHeight: 400,
    minWidth: 300,
    show: false,
    autoHideMenuBar: true,
    ...(process.platform === 'linux' ? { icon } : {}),
    webPreferences: {
      preload: join(__dirname, '../preload/index.js'),
      sandbox: false,
      devTools: true
    },
    frame: false,
    transparent: true,
    alwaysOnTop: true,
    icon: path.join(process.env['ELECTRON_RENDERER_URL'], 'flarecast.svg')
  })

  mainWindow.setContentProtection(true);
转载请注明原文地址:http://anycun.com/QandA/1745229910a90519.html