Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_appearance toggling skips first change when starting in dark mode #4985

Closed
bsvh opened this issue Feb 9, 2024 · 4 comments · Fixed by #5135
Closed

get_appearance toggling skips first change when starting in dark mode #4985

bsvh opened this issue Feb 9, 2024 · 4 comments · Fixed by #5135
Labels
bug Something isn't working

Comments

@bsvh
Copy link

bsvh commented Feb 9, 2024

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 dark to 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.

@bsvh bsvh added the bug Something isn't working label Feb 9, 2024
@bsvh
Copy link
Author

bsvh commented Feb 9, 2024

I also tried this on gnome using the quick settings toggle to change back and forth, and the issue is present there as well.

@MartinNowak
Copy link
Contributor

MartinNowak commented Mar 8, 2024

Apparently introduced with 3eaba4e.
The rewritten WaylandConnection doesn't implement get_appearance yet

fn terminate_message_loop(&self) {

and falls back to the default.
/// Retrieve the current appearance for the application.
fn get_appearance(&self) -> Appearance {
Appearance::Light
}

#5135

MartinNowak added a commit to MartinNowak/wezterm that referenced this issue Mar 9, 2024
- was dropped with wayland reimplementation (wez#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes and reload config
MartinNowak added a commit to MartinNowak/wezterm that referenced this issue Mar 9, 2024
- was dropped with wayland reimplementation (wez#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
@wez wez closed this as completed in #5135 May 5, 2024
wez pushed a commit that referenced this issue May 5, 2024
- was dropped with wayland reimplementation (#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
Copy link
Contributor

github-actions bot commented Jun 5, 2024

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 5, 2024
saep pushed a commit to saep/wezterm that referenced this issue Jul 14, 2024
- was dropped with wayland reimplementation (wez#4777, 3eaba4e)
- get appearance from xdg desktop portal
- advise all windows of appearance changes to reload config
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@MartinNowak @bsvh and others