weisJ / auto-dark-mode

IDEA plugin to automatically apply system theme settings on macOS and Windows.
https://plugins.jetbrains.com/plugin/14076-auto-dark-mode
MIT License
53 stars 14 forks source link

INFO: Jetbrains Runtime 21 has now an API to detect the OS theme #85

Open bric3 opened 5 months ago

bric3 commented 5 months ago

So this is not an issue report but more of a discussion or information.

It seems the latest JBR 21 build, has now an API to detect whether the OS is dark, that said, at this time the implementation seems to only support Linux.

            String[] themesOrder = {DARK_THEME_NAME, LIGHT_THEME_NAME, DARK_THEME_NAME};
            Toolkit.getDefaultToolkit().addPropertyChangeListener("awt.os.theme.isDark", evt -> {
                currentTheme = currentTheme();
            });

https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-21.0.3b453.2 https://github.com/JetBrains/JetBrainsRuntime/commit/16150a0ebec46e46e58d14fe8c033e6e100b53ea https://youtrack.jetbrains.com/issue/JBR-6376

This is needed for Linux in the first place, but if the API can be made generic, some stuff from IDEA on macOS/Windows can be moved there as well. See IJPL-54591 for the discussion and suggestions. There are plugins that implement this, for example, here: https://github.com/weisJ/auto-dark-mode/blob/master/linux/gtk/src/main/java/com/github/weisj/darkmode/platform/linux/gtk/GtkThemeMonitorService.kt

weisJ commented 5 months ago

Great to hear. Maybe there is a future where this plugin isn’t needed after all 👍🏼

bric3 commented 5 months ago

Ideally this should be something in the the JDK upstream.

Like other window decorations like macos vibrancy, windows acrylic, etc. One can dream :)