Repository: alacritty/alacritty (language: rust)

Issue:
Background blur
Which operating system does the issue occur on? **macOS 10.13.2**

If on linux, are you using X11 or Wayland? **N/A**

Transparent background works nicely; however, for many contexts this is essentially unusable; you also need a background *blur* setting (as Terminal.app and iTerm.app have on macOS).




Discussion / hints:
Here's a comparison with both Terminal.app and Alacritty.app set to 67% opacity—Alacritty is on the left, Terminal on the right:

<img width="720" alt="alacritty-terminal-compare" src="https://user-images.githubusercontent.com/2403023/34387413-3c52c0d2-eaeb-11e7-8bfe-dd8fb10fe47a.png">

As you can see, the background on the left has no blur, so the content behind it is totally visible through it. (For lots of people, that may be exactly what's desired. But not for me!)
Interesting request 🙂 
I was curious if this request applies to Linux too - apparently not, because compton already allows this:

-------

![image](https://user-images.githubusercontent.com/1177900/34395549-66837650-eb61-11e7-8909-c0c77bd4f918.png)

--------------

If you are interested to achieve similar results, play with compton's `--blur-background` and `--blur-kern` CLI arguments.
fwiw, this doesn't invalidate the issue in any way (I would love to have a blur option, in fact), but with iTerm2 I've found that I always end up setting no blur and leaving it to a low transparency setting so I can at least get some transparent effect at least: The blurring always incurs a substantial cpu load increase. If this can be done in a way that effectively leverages the GPU, it would be lightweight enough to not appreciably impact battery life. Otherwise, it's less attractive at least for me.
Anyone looking at implementing this can also look at KDE's new blur implementation which is meant to be ~~lightweight~~ more efficient than a Gaussian blur:
https://www.reddit.com/r/kde/comments/7szqqk/i_implemented_a_new_blur_effect_in_kde_it/ 

The technique used is described in: https://community.arm.com/cfs-file/__key/communityserver-blogs-components-weblogfiles/00-00-00-26-50/siggraph2015_2D00_mmg_2D00_marius_2D00_notes.pdf 
Would be nice to have in win10 as well.
https://docs.microsoft.com/en-us/windows/uwp/design/style/acrylic
I'd like to support this (kinda vain, I admit it) request. It's a (very) nice to have.
may I ask is there any update on this?
If there is any progress on an issue, the issue will be updated. Asking about updates when there is none is unlikely to speed things up.

I also do not expect this to get fixed anytime soon, since it's very low priority for me. Unless someone else sends a simple PR which adds this, it's unlikely to be resolved in the near future.
A side note: Comptons blur used to be quite expensive on the CPU side IIRC, so that is not really a viable option for mobile users. Also, compton != linux, there is a growing crowd of people using Wayland. As such, I as well would like this to be a capability of the terminal. Alacritty already uses the GPU for rendering, hence it might be easier to leverage shaders for the blur as well to get an useful yet efficient blur implementation.
>Alacritty already uses the GPU for rendering, hence it might be easier to leverage shaders for the blur as well to get an useful yet efficient blur implementation.

This is not how it works, alacritty can't possibly do blur because it doesn't know about contents you have on screen. That being said, blur is done by system's compositor on all display servers  I'm aware of. The only thing that alacritty can do is ask for blur your system's compositor, and hope that it blurs things.
@kchibisov This is not 100% true, technically. There are ways to get some part of the screen buffer, and blur that. Similar as to how a magnifier application or a screenshot tool work. IIRC URxvt supports blur through that as well. It is quite ugly though, because the blur is not updated when the URxvt window moves. My hope would be that this can be improved a lot if the blur is done on the GPU. But an implementation in the compositor definitely is cleaner and can perform way better.
You can make blur, by making screen shot of the entire screen, sure, but you can't make it work cross platform that way. Also, this is the most stupid way to make blur you can imagine, and I only saw that on X11.
Has anyone had luck getting the blur to work with the KDE Plasma blur? If so, what does the config file look like.
^ Same
+1 for Linux KDE plasma. Not to crowd comments but +1...
There is no blur, that's why this issue is still open. Please don't reply to issues unless you have relevant comments.
Found a hack for KDE blur! Not too sure about the implementation itself, but found it [here](https://www.reddit.com/r/kde/comments/6jzuwu/konsole_and_yakuake_blur/djilli2/) and tweaked it for Alacritty. 
Right when I was about to switch from this beautiful terminal! 
Add the following to your .zsh or .bash config, make sure you have xdotool and voila! 
```
if [[ $(ps --no-header -p $PPID -o comm) =~ '^alacritty$' ]]; then
        for wid in $(xdotool search --pid $PPID); do
            xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $wid; done
fi
```

Now I need to figure out if and how to mess with the blur opacity itself.. maybe messing with Alacritty's opacity would do.
If devs feel this implementation isn't too expensive(shouldn't be for the fastest terminal), maayybe this could be an opt-in feature for linux/KDE users? Maybe just mention in the docs?

edit: looks like the blur settings are related to KDE blur itself. Very satisfying results. Now need to check for performance tolls, if any.
> If devs feel this implementation isn't too expensive(shouldn't be for the fastest terminal), maayybe this could be an opt-in feature for linux/KDE users?

The problem with this is that it's not a standard by a long shot. Implementing a feature for a single desktop environment across all platforms is not something I am interested in. 
To enable blur effect in Alacritty install Kwin script "Force Blur"  then add Alacritty in Force blur script setting and reboot your system you will be able to see transparent blur background in Alacritty !!!
> To enable blur effect in Alacritty install Kwin script "Force Blur" then add Alacritty in Force blur script setting and reboot your system you will be able to see transparent blur background in Alacritty !!!


edit: nvm, I did not see how to enable scripts in `force-blur`. Doing that and adding `alacritty` gets the job done perfectly :+1: 

could you mention what the script looks like? For some reason that code I mentioned stopped working, maybe cause I recently integrated tmux? Your script would be helpful :smile: 
@yashank09 Thanks) worked right away!
@master-of-zen we're probably pissing off the maintainers, but I'd suggest using @Nishant0073 's solution for KDE, specially if you have force-blur enabled already. Im sure it'll be less of a performance hit that way. 
Taking a screenshot of an area and blurring the image is possible in X11, as you can see in my video [https://www.youtube.com/watch?v=ZOBBZv9B3Q8](https://www.youtube.com/watch?v=ZOBBZv9B3Q8)
The question is how to take a screenshot of an area behind the window?
In other words: is there a way to fetch an image of planes bellow the window and blur it?
However the image can not be refreshed, unless... of course, the window is closed and the screenshot is retaken.
We can even draw blurred image on a cairo surface: [https://www.youtube.com/watch?v=n6EyhoC5T9Y](https://www.youtube.com/watch?v=n6EyhoC5T9Y)
The brurmenu, as seen in the previous video, is here: https://github.com/Misko-2083/blurmenu
For blurring, stackblur algorhytm is ideal, very fast, a few milliseconds is required to blur entire desktop + it's multi-threaded.
Above all it gives very good image results.
By using [window-vibrancy](https://lib.rs/crates/window-vibrancy) I was able to `apply_blur` during `fn create_window` on `Processor`. This library also supports Acrylic but the performance when moving the window is very slow (I have an RTX 3070).

I haven't tested macOS but I could do so later today.

![image](https://user-images.githubusercontent.com/46565598/166973746-7c294a0c-92ba-44c8-bf04-ae2f3ae3becb.png)

> By using [window-vibrancy](https://lib.rs/crates/window-vibrancy) I was able to `apply_blur` during `fn create_window` on `Processor`. This library also supports Acrylic but the performance when moving the window is very slow (I have an RTX 3070).

@doctor-amaton, I'm able and very keen to help you test on macos/windows!  

FWIW, I'd already started looking at this, but just starting out with Rust and [didn't get far](https://github.com/adamazing/alacritty/pull/1/files) 😅 . I've just pushed what little I've done to my own fork and created a PR on my own master branch so the diff is easy to see. I've been banging my head against a wall trying to build on Windows -- `cargo build` on master branch succeeds, `cargo build` on my spike branch fails to link.




@adamazing that's great! 

I'm not sure what issue are you running into for building on windows, but I'll try to build your branch and if I find something I'll update this comment. We're so close to a PR for this.
To blur or not to blur, that's the question.

By some term-guy
Sadly I don't know any Rust (yet) but I found this and thought I might share.
https://github.com/tauri-apps/window-vibrancy
It's written in Rust too and seems pretty lightweight afaict, maybe just use this and mark blur as an experimental feature?
This only works for mac and windows, but Linux doesn't seem to be a target for this enhancement anyway as the installed compositor handles blur. I hope someone finds this useful, but maybe it is just considered bloat which is understandable.
I have achieved a nice transparent and blur effect with the config with xdtool script in the .zshrc file and a plugin from [xiyaowong/nvim-transparent](https://github.com/xiyaowong/nvim-transparent)


```
#Alacitty.yml
window:
   opacity: 0.8
```

```
#alacritty hack for blur in ~/.zshrc
if [[ $(ps --no-header -p $PPID -o comm) =~ '^alacritty$' ]]; then
        for wid in $(xdotool search --pid $PPID); do
            xprop -f _KDE_NET_WM_BLUR_BEHIND_REGION 32c -set _KDE_NET_WM_BLUR_BEHIND_REGION 0 -id $wid; done
fi
```
![2022-10-08_23-14](https://user-images.githubusercontent.com/1525214/194714776-305a2d31-eefe-4763-a4c9-37d4363c0dad.jpg)

My system is Manjaro with KDE Plasma, X11/Xorg
@chriskrycho @adamazing @yashank09  @Dakai  @doctor-amaton  has anyone been able to blur alacritty on macos?
If yes, could you please tell me how?
> > By using [window-vibrancy](https://lib.rs/crates/window-vibrancy) I was able to `apply_blur` during `fn create_window` on `Processor`. This library also supports Acrylic but the performance when moving the window is very slow (I have an RTX 3070).
> 
> @doctor-amaton, I'm able and very keen to help you test on macos/windows!
> 
> FWIW, I'd already started looking at this, but just starting out with Rust and [didn't get far](https://github.com/adamazing/alacritty/pull/1/files) 😅 . I've just pushed what little I've done to my own fork and created a PR on my own master branch so the diff is easy to see. I've been banging my head against a wall trying to build on Windows -- `cargo build` on master branch succeeds, `cargo build` on my spike branch fails to link.

I just decided to try this because I've been working with that lib for one of my personal projects so I took a few minutes to hop around and find this function on my own. Unfortunately, it appears on MacOS, window vibrancy and OpenGL are mutually exclusive. If I enable vibrancy, I get no video. A pty is still allocated and I can interact with the console, verifying the commands ran with another working terminal, but I'm doing so blind because the OpenGL code doesn't make it to the display. I seem to recall having trouble with this when I used electron too, in which case that would explain it, since Chrome uses (or at least used) OpenGL for HW acceleration.

Then again, I could be totally off-base. I haven't done much work in the non-web-desktop-application space other than QML, so I'm not familiar with the APIs and limitations. If someone else wants to take a crack at it, I'm really hoping you can prove me wrong.
Alacritty should automatically support vibrancy settings on MacOS when https://github.com/rust-windowing/winit/issues/538 is complete as it uses `winit` to create and manage windows.

Fix patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2fbf97fcbff..80abac434f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
 - Support startup notify protocol to raise initial window on Wayland/X11
 - Debug option `prefer_egl` to prioritize EGL over other display APIs
 - Inline vi-mode search using `f`/`F`/`t`/`T`
+- `window.blur` config option to request blur for transparent windows
 
 ### Changed
 
diff --git a/Cargo.lock b/Cargo.lock
index a0d4ec422aa..a3d81d88bcb 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2386,9 +2386,9 @@ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
 
 [[package]]
 name = "winit"
-version = "0.29.2"
+version = "0.29.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "b829f75d02fe1e225b97c91a04c326900147a50234d1141a1cbe215ce8798c11"
+checksum = "161598019a9da35ab6c34dc46cd13546cba9dbf9816475d4dd9a639455016563"
 dependencies = [
  "ahash",
  "android-activity",
diff --git a/alacritty/Cargo.toml b/alacritty/Cargo.toml
index 0752b2d289c..890b5226628 100644
--- a/alacritty/Cargo.toml
+++ b/alacritty/Cargo.toml
@@ -41,7 +41,7 @@ serde_json = "1"
 serde_yaml = "0.9.25"
 toml = "0.8.2"
 unicode-width = "0.1"
-winit = { version = "0.29.2", default-features = false, features = ["rwh_05", "serde"] }
+winit = { version = "0.29.3", default-features = false, features = ["rwh_05", "serde"] }
 
 [build-dependencies]
 gl_generator = "0.14.0"
diff --git a/alacritty/src/config/window.rs b/alacritty/src/config/window.rs
index 9d40b5ad345..bb7c40806d7 100644
--- a/alacritty/src/config/window.rs
+++ b/alacritty/src/config/window.rs
@@ -48,6 +48,9 @@ pub struct WindowConfig {
     /// Background opacity from 0.0 to 1.0.
     pub opacity: Percentage,
 
+    /// Request blur behind the window.
+    pub blur: bool,
+
     /// Controls which `Option` key should be treated as `Alt`.
     #[cfg(target_os = "macos")]
     option_as_alt: OptionAsAlt,
@@ -66,17 +69,18 @@ impl Default for WindowConfig {
     fn default() -> Self {
         Self {
             dynamic_title: true,
+            blur: Default::default(),
+            embed: Default::default(),
+            padding: Default::default(),
+            opacity: Default::default(),
             position: Default::default(),
+            identity: Default::default(),
+            dimensions: Default::default(),
             decorations: Default::default(),
             startup_mode: Default::default(),
-            embed: Default::default(),
-            decorations_theme_variant: Default::default(),
             dynamic_padding: Default::default(),
-            identity: Identity::default(),
-            opacity: Default::default(),
-            padding: Default::default(),
-            dimensions: Default::default(),
             resize_increments: Default::default(),
+            decorations_theme_variant: Default::default(),
             #[cfg(target_os = "macos")]
             option_as_alt: Default::default(),
         }
diff --git a/alacritty/src/display/window.rs b/alacritty/src/display/window.rs
index 5606ca4f0b0..f5128e752ea 100644
--- a/alacritty/src/display/window.rs
+++ b/alacritty/src/display/window.rs
@@ -167,6 +167,7 @@ impl Window {
             .with_theme(config.window.decorations_theme_variant)
             .with_visible(false)
             .with_transparent(true)
+            .with_blur(config.window.blur)
             .with_maximized(config.window.maximized())
             .with_fullscreen(config.window.fullscreen())
             .build(event_loop)?;
@@ -343,6 +344,10 @@ impl Window {
         self.window.set_transparent(transparent);
     }
 
+    pub fn set_blur(&self, blur: bool) {
+        self.window.set_blur(blur);
+    }
+
     pub fn set_maximized(&self, maximized: bool) {
         self.window.set_maximized(maximized);
     }
diff --git a/alacritty/src/window_context.rs b/alacritty/src/window_context.rs
index 5c017cab8f3..a80aecca4ab 100644
--- a/alacritty/src/window_context.rs
+++ b/alacritty/src/window_context.rs
@@ -345,8 +345,9 @@ impl WindowContext {
         #[cfg(target_os = "macos")]
         self.display.window.set_option_as_alt(self.config.window.option_as_alt());
 
-        // Change opacity state.
+        // Change opacity and blur state.
         self.display.window.set_transparent(!opaque);
+        self.display.window.set_blur(self.config.window.blur);
 
         // Update hint keys.
         self.display.hint_state.update_alphabet(self.config.hints.alphabet());
diff --git a/extra/man/alacritty.5.scd b/extra/man/alacritty.5.scd
index 57225452fc8..0d4c28cf9d4 100644
--- a/extra/man/alacritty.5.scd
+++ b/extra/man/alacritty.5.scd
@@ -133,6 +133,12 @@ This section documents the *[window]* table of the configuration file.
 
 	Default: _1.0_
 
+*blur* <boolean> _(works on macOS/KDE Wayland)_
+
+	Request compositor to blur content behind transparent windows.
+
+	Default: _false_
+
 *startup_mode* "Windowed" | "Maximized" | "Fullscreen" | "SimpleFullscreen"
 
 	Startup mode (changes require restart)


Test patch: