Change WezTerm blurred Window Background & Opacity on Focus

Change WezTerm blurred Window Background & Opacity on Focus

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

Roman Zipp, December 7th, 2024

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.

local wezterm = require 'wezterm'

local config = wezterm.config_builder()
local opacity = 0.9
  
wezterm.on('window-focus-changed', function(window, pane)
    local overrides = window:get_config_overrides() or {}

    if window:is_focused() then
        overrides.window_background_opacity = 1
    else
        overrides.window_background_opacity = opacity
    end

    window:set_config_overrides(overrides)
end)
  
config.window_background_opacity = opacity
config.macos_window_background_blur = 30
  
return config

Sources