sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
803 stars 39 forks source link

Auto Color Scheme Switching not Working on Ubuntu 21.10 #5194

Open cem-okulmus opened 2 years ago

cem-okulmus commented 2 years ago

Description of the bug

The "auto" setting in colour scheme allows users to define two separate colour schemes, one for light mode and one for dark mode, and have Sublime switch to them if dark mode is turned on or off. This used to work and I believe the most recent update broke this (though this regression might be from an even earlier update and I just didn't notice or update until now).

Steps to reproduce

  1. First step Open Sublime Text 4, Build 4126 on Ubuntu 21.10.
  2. Set up the auto colour scheme, choosing two separate schemes for light and dark mode
  3. switch between dark and light mode in the settings (shown below)

Expected behavior

You'd expect Sublime to switch to the chosen theme for light or respectively dark mode.

Actual behavior

The colour scheme stays the same, though the title bar does change (as that's provided by the shell, I'd assume).

Here is recording of the behaviour: Peek 2022-01-15 16-36

Sublime Text build number

4126

Operating system & version

Ubuntu 21.10

(Linux) Desktop environment and/or window manager

Gnome 40.4.0

Additional information

No response

OpenGL context information

No response

BenjaminSchaaf commented 2 years ago

I can't reproduce that here. Does it happen in safe mode?

cem-okulmus commented 2 years ago

The gif you see there is in safe mode (I guess it's not easy to see unless you magnify).

Hmm, I'm not sure what's causing this. So I installed Ubuntu 21.10 on a VM and installed Sublime there, and yeah, I don't get it there, the colour switching works. I tried it again on my machine (outside the VM) when disabling all Gnome extensions (that don't already ship with Ubuntu) and it's still the same. I guess given that evidence, the bug must be due to something on my current installation of Ubuntu, but not sure how anything could cause only a single program to behave like this. I don't see issues like this with any other app that supports automatic switching to dark mode.

BenjaminSchaaf commented 2 years ago

Does it switch color schemes after restarting ST?

cem-okulmus commented 2 years ago

It does not, it always stays at whatever color scheme was chosen for light theme. What exactly does Sublime look for (which API, or setting) to determine if the current mode on Linux should be light or dark? That might give a hint as to what's causing the problem in my current install of Ubuntu.

BenjaminSchaaf commented 2 years ago

@cem-okulmus We grab the setting gtk-theme from org.gnome.desktop.interface, apply the theme to a GtkStyleContext and grab the selected background color. If the background color has all 3 components < 0.5 we switch to dark mode.

deathaxe commented 2 years ago

I see the same issue with ST4126 on ElementaryOS 6.1. ST ignores any change between light and dark system themes. It always uses the light variant.

cem-okulmus commented 2 years ago

So, just as a minor update to this problem. I recently reinstalled Ubuntu for the new release 22.04. At first, Sublime Text suddenly had working colour scheme switching again. I brought over my old config data, and the bug reappeared. Before doing this, I had backed up the previous contents of the .config/sublime-text folder and restored it. However, this did not fix the issue, it remained. Is there perhaps some other folder where sublime is saving some config files?

At any rate, I believe the way Sublime Text is deciding which theme to apply is outdated, at least on Gnome 42, which ships with a new dark style preference, some info on it here https://blogs.gnome.org/alexm/2021/10/04/dark-style-preference/ . It seems like a new freedesktop standard, with implementations in multiple desktop interfaces and easily accessible via DBus. Trying to guess via looking up background colours feels very ad-hoc and unreliable in comparison to that, at least to me.

colinkiama commented 2 years ago

At any rate, I believe the way Sublime Text is deciding which theme to apply is outdated, at least on Gnome 42, which ships with a new dark style preference, some info on it here

I mention this here too: #5350

mroach commented 2 years ago

I have the same issue on Fedora 36 with standard GNOME+Wayland. I'm using an extension Night Theme Switcher to switch my system automatically between light and dark. Other apps switch, but not Sublime Text.

    "theme": "Adaptive.sublime-theme",
    "light_theme": "gruvbox.sublime-theme",
    "dark_theme": "ayu-mirage.sublime-theme",

    "color_scheme": "auto",
    "light_color_scheme": "gruvbox (Light) (Medium) NDC.sublime-color-scheme",
    "dark_color_scheme": "gruvbox (Dark) (Medium).sublime-color-scheme",

This happens with theme as adaptive or "auto"

frithrah commented 2 years ago

I wonder if my commit to the xfce4-night-mode switcher may help some. See how I had to include the gtk-theme setting for the benefit of Sublime Text...

https://github.com/bimlas/xfce4-night-mode/commit/4c6ae90598880983123fabdbe3d43236117b0bbd