Is it possible to make a BrowserWindow
, in electron, transparent with blur? In that it blurs all background content, including apps and the wallpaper.
And if possible, how would I accomplish this?
Here are some code I've tried.index.js
:
let win = new BrowserWindow({
fullscreen: true,
fullscreenable: false,
frame: false,
skipTaskbar: true,
resizable: false,
movable: false,
show: false,
alwaysOnTop: true,
transparent: true
})
style.css
:
html, body {
width: 100vw;
height: 100vh;
margin: 0;
padding: 0;
background-color: rgba(0, 0, 0, 0.5);
color: rgb(255, 255, 255);
backdrop-filter: blur(4px);
}
The html is just a body with a h1 tag with text in it.
Although this only creates a black background in the window.
I read something about this:
webPreferences: {
experimentalFeatures: true
}
But can't get it to work.
I have compton running. Maybey it has to do with that. Or the compositing engine in general?
Thanks in advance!
If you want to use CSS (CSS3) do this: filter: blur(5px) brightness(0.5); just set the values to whatever you want.. put all your text in the div whose class is "text" and leave the div with class "background" empty..
To make an Electron app run in full-screen mode when it's started, pass the following configuration option when creating the BrowserWindow instance: mainWindow = new BrowserWindow({fullscreen: true});
In order to make our window transparent, we need to provide the transparent and frame property to true and false respectively: const {BrowserWindow} = require('electron') let win = new BrowserWindow({ width: 800, height: 600, transparent:true, frame: false }) win.show()
Transparent windows are not resizable. Setting resizable to true may make a transparent window stop working on some platforms. The blur filter only applies to the web page, so there is no way to apply blur effect to the content below the window (i.e. other applications open on the user's system).
Setting resizable to true may make a transparent window stop working on some platforms. The blur filter only applies to the web page, so there is no way to apply blur effect to the content below the window (i.e. other applications open on the user's system). On Windows operating systems, transparent windows will not work when DWM is disabled.
On Windows operating systems, transparent windows will not work when DWM is disabled. On Linux users have to put --enable-transparent-visuals --disable-gpu in the command line to disable GPU and allow ARGB to make transparent window, this is caused by an upstream bug that alpha channel doesn't work on some NVidia drivers on Linux.
Actually, it is possible, with a little bit of magic. I have no idea why nobody pointed that out, but there exists a small utility called electron-acrylic-window, which allows you to do exactly that. You can choose between the acrylic ("frosted") and blur effects, as well as change the color of the window and the opacity.
Under the hood, it uses node-gyp and low-level C++ code to render the page however you like. It's pretty easy to implement in Javascript.
The major drawback is that anything that is remotely transparent (and not above anything with a solid color) will be rendered as totally transparent.
index.js
const { BrowserWindow } = require('electron-acrylic-window');
// import { BrowserWindow } from 'electron-acrylic-window';
win = new BrowserWindow({
...,
frame: false,
vibrancy: {
theme: 'light', // (default) or 'dark' or '#rrggbbaa'
effect: 'acrylic', // (default) or 'blur'
disableOnBlur: true, // (default)
}
});
// alternatively use these to
// dynamically change vibrancy
win.setVibrancy([options])
// or
setVibrancy(win, [options])
style.css
body {
background-color: transparent;
}
.watev {
background-color: black;
}
It's not possible to blur other apps in the background. https://www.electronjs.org/docs/api/frameless-window#limitations
The blur filter only applies to the web page, so there is no way to apply blur effect to the content below the window (i.e. other applications open on the user's system).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With