Change WezTerm blurred Window Background & Opacity on Focus

Enabled blurred window background with WezTerm on macOS and toggle when focussing the window

Change WezTerm blurred Window Background & Opacity on Focus
07 Dec 2024
|
2 min read

Make sure you have a .wezterm.lua Config file ready in your home directory and it's correctly loaded by WezTerm. Refer to the Configuration Docs.

WezTerm background opacity & blur is toggled when the window is in focus

The Config

The configuration as a constant opacity variable which is just there for consistency. An initial background opacity will be set when the configuration is read the first time.

We then listen to the window-focus-changed event to - get any previous and - set a new config override.

This is inteded to run on macOS, apparently you can build a similar effect on Windows.

 1local wezterm = require 'wezterm'
 2
 3local config = wezterm.config_builder()
 4local opacity = 0.9
 5  
 6wezterm.on('window-focus-changed', function(window, pane)
 7    local overrides = window:get_config_overrides() or {}
 8
 9    if window:is_focused() then
10        overrides.window_background_opacity = 1
11    else
12        overrides.window_background_opacity = opacity
13    end
14
15    window:set_config_overrides(overrides)
16end)
17  
18config.window_background_opacity = opacity
19config.macos_window_background_blur = 30
20  
21return config

Sources


Read more...