1

With firefox under wayland (Hyprland), if I set gtk-application-prefer-dark-theme={0,1} in ~/.config/gtk3.0/settings.ini and then launch firefox it correctly determines the system theme.

How do I set this at runtime?

gsettings set org.gnome.desktop.interface color-scheme 'prefer-{light, dark}'
gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita{,-dark}'

have no effect (other than setting the value in the store), i.e. nothing changes, and restarting firefox has no effect, regardless of whether gtk-theme-prefer-dark-theme is set or not.

Are these settings gtk{4,2} values? If so, how do I set whatever gtk-application-prefer-dark-theme sets at runtime?

1 Answer 1

1

The short answer is: by setting gsettings set org.gnome.desktop.interface gtk-theme 'Adwaita{,-dark}'. This is queried in nsLookAndFeel.cpp, which responds to change events properly---as you can confirm with gdb after waiting half an hour for firefox to build :D It actually uses an amusing hack:

static bool GetThemeIsDark() {
  GdkRGBA bg, fg;
  GtkStyleContext* style = GetStyleContext(MOZ_GTK_WINDOW);
  gtk_style_context_get_background_color(style, GTK_STATE_FLAG_NORMAL, &bg);
  gtk_style_context_get_color(style, GTK_STATE_FLAG_NORMAL, &fg);
  return RelativeLuminanceUtils::Compute(GDK_RGBA_TO_NS_RGBA(bg)) <
         RelativeLuminanceUtils::Compute(GDK_RGBA_TO_NS_RGBA(fg));
}

This simply tests if the foreground is brighter than the background, which is the definition of a light theme I guess.

The longer answer is that there appears to be a bug, and sometimes prefers-color-scheme isn't getting set or indeed exists in multiple states across different windows. Themes which don't rely on querying the window---i.e. system themes---are unaffected. User themes don't update properly, hence my problem.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .