wezterm
wezterm copied to clipboard
get_appearance toggling skips first change when starting in dark mode
What Operating System(s) are you seeing this problem on?
Linux Wayland
Which Wayland compositor or X11 Window manager(s) are you using?
Sway
WezTerm version
20240203-110809-5046fc22
Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?
Yes, the toggling didn't work at all.
Describe the bug
I'm using get_appearance as shown here to toggle between a like and dark theme. When I start a new process (i.e., when there aren't any wezterm windows open or if I run wezterm start --always-new-process) and I am already in dark mode, switching my desktop to light mode does not change wezterm's appearance. If I then switch back to dark mode, and switch again to light mode, wezterm's appearance is updated. Subsequent changes work correctly.
This does not happen when I start wezterm and am already in light mode. In this instance, changing to dark mode immediately switches to dark mode, and subsequent changes work correctly.
I am using darkman as my colors-scheme switcher.
To Reproduce
This is easily reproduced under sway using darkman.
darkmanctl set darkto get into dark mode- With no wezterm instances running, run wezterm
- toggle to light mode using
darkmanctl toggle(nothing will happen to wezterm) - toggle back to dark mode with
darkmanctl toggle - toggle once more to light mode with
darkmanctl toggle(wezterm is now using the light theme)
Configuration
local wezterm = require 'wezterm'
wezterm.add_to_config_reload_watch_list(wezterm.config_dir)
function get_appearance()
if wezterm.gui then
return wezterm.gui.get_appearance()
end
return 'Dark'
end
function scheme_for_appearance(appearance)
if appearance:find 'Dark' then
return 'Modus-Vivendi'
else
return 'Modus-Operandi-Tinted'
end
end
function weight_for_appearance(appearance)
if appearance:find 'Dark' then
return "Medium"
else
return "Light"
end
end
return {
window_decorations = 'RESIZE',
term = 'wezterm',
enable_wayland = true,
color_scheme = scheme_for_appearance(get_appearance()),
font = wezterm.font {
family = "Iosevka Comfy Motion",
weight = weight_for_appearance(get_appearance()),
harfbuzz_features = { "calt" },
},
font_size = 11,
use_fancy_tab_bar = false,
hide_tab_bar_if_only_one_tab = true,
}
Expected Behavior
The theme is changed to light theme immediately
Logs
Nothing shows up in the logs
Anything else?
I tried this using nightly, but nightly didn't seem to work at all with get_appearance. The theme was always the light theme no matter what I did. I tried this on the nightly appimage and by building it from source.
I also tried this on gnome using the quick settings toggle to change back and forth, and the issue is present there as well.
I can confirm that the toggling hasn't worked at all in the nightly for the past few weeks.
wezterm.gui.get_appearance() always returns 'Light', no matter the actual theme setting of the OS.
Fedora 39 / GNOME 45.4
Apparently introduced with 3eaba4e3d6cfa0c97436dc9aea46ec11169dccb0. The rewritten WaylandConnection doesn't implement get_appearance yet https://github.com/wez/wezterm/blob/22424c3280cb21af43317cb58ef7bc34a8cbcc91/window/src/os/wayland/connection.rs#L161 and falls back to the default. https://github.com/wez/wezterm/blob/22424c3280cb21af43317cb58ef7bc34a8cbcc91/window/src/connection.rs#L66-L69
→ #5135
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.