You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Eclipse should be able to 'follow system theme' (light/dark) #2440
I would like to be able to tell Eclipse to 'follow the system theme' and use a Light or Dark theme based on what the operating system preference is set to.
Community
I understand suggesting an enhancement doesn't mandate anyone to implement it. Other contributors may consider this suggestion, or not, at their own convenience. The most efficient way to get it fixed is that I implement it myself and contribute it back as a good quality patch to the project.
The IDE is already supposed to switch to dark theme when system is dark. So please provide details about your setup to hopefully reproduce this issue.
But on a side note, if you want the strongest possible integration with the system theme, you should simply disable theming (untick checkbox in the preference page and restart Eclipse IDE) and you'll get the widgets following the system theme as Eclipse doesn't override it.
The IDE is already supposed to switch to dark theme when system is dark.
It does switch between light/dark with a fresh workspace. But once a theme has been set it won't.
If the themeid setting does not exist in .metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs then the system light or dark theme is used. However, once a user sets the theme in preferences themeid is set to the id of the theme and this auto setting no longer works.
In our RCP app we workaround this by deleting the org.eclipse.e4.ui.css.swt.theme.prefs file if the user chooses "Auto" which resets it.
Thanks for the info @mickaelistria ; been using Eclipse for around 20 years and always used theming. As @Phillipus says though, a theme was initially selected already in my installation so restarting after going to dark mode does not help. An explicit 'follow system theme' or similar would be very useful.
I am not sure if disabling theming is supposed to use OS colors in dark mode, but it does not.
As I said, all you have to do is delete the <workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs file and it will follow the system theme.
Or there could just be an additional "virtual" option in the themes drop-down menu for enabling to follow the system theme.
That's what I do. Selecting this deletes the workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs file.
Or there could just be an additional "virtual" option in the themes drop-down menu for enabling to follow the system theme.
That's what I do. Selecting this deletes the workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs file.
Sorry, I missed that comment. Sounds like a simple and sufficient approach to address this.
Or there could just be an additional "virtual" option in the themes drop-down menu for enabling to follow the system theme.
There used to be a "System" theme: https://eclipse.dev/eclipse/news/4.18/platform.html#system-theme
But I removed it some time ago with 9328b2d as I realized default SWT behavior is supposed to follow the system GTK theme (eg Adwaita-dark) so basically this System theme was not so relevant to address the problem of following system colors.
Note that to make it work, the light/dark setting in gnome settings is not sufficient: the relevant setting is the "Appearance/Legacy Applications" one you can find in gnome-tweaks. I guess the current gnome settings is GTK4 only and is ignored as long as GTK3 is used by SWT; but there might still be some possible way to pass the right GTK3 theme according to GTK4 settings; but I don't think it will make it into SWT as the priority should be to just use directly GTK4.
This is really just supposed to be a 'first time initialization' thing, i.e. it choses some sane default theme.
But there are multiple light themes and there can be multiple dark themes
The user would need to be able to select a preferred dark theme and a preferred light theme.
To consider:
Having such an 'Auto' mode would suggest that we can handle theme changes on-the-fly without restart - which we can't.
I am not sure whether we should add this in the current state.
Technically, we would therefore need to:
Optional, but probably way overdue: Make it possible to explicitly flag a theme as isLight or isDark and not derive it from the theme ID via some string comparison heuristics.
Improve the UI
Add an 'Inherit from system' / 'Auto' option
While still allowing the user to chose which light and dark themes to use
React on changed Windows light<->dark theme
If inheritance is enabled:
Apply the theme change
Inform the user that Windows theme changed, but an Eclipse restart is needed
As I said, all you have to do is delete the <workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefs file and it will follow the system theme.
@Phillipus - that does not work for me, for whatever reason. I removeds the existing file, closed Eclipse, and started it again but I was still in light mode while the OS was in dark mode.
Regarding the wider discussion: I think ideally there would be a way to say 'follow System dark/light setting'. And yes, there may be multiple light and dark theme modes but for starters it would be great to be able to toggle between the build in dark and light modes through a virtual theme or checkbox in the preferences page.
that does not work for me, for whatever reason. I removeds the existing file, closed Eclipse, and started it again but I was still in light mode while the OS was in dark mode.
Which OS? Works for me on Windows and Mac (Linux might not work)
that does not work for me, for whatever reason. I removeds the existing file, closed Eclipse, and started it again but I was still in light mode while the OS was in dark mode.
Which OS? Works for me on Windows and Mac (Linux might not work)
I can confirm that this follows the system theme on macOS, but it doesn't on Fedora KDE.
Does it work for plain SWT application in Fedora KDE ?
If plain SWT apps do follow the system colors, then it means that the Display.getSystemColor() do provide the right information; and we can then rely on those colors more reliably than on other settings in order to determine what is the closer theme to system.
Activity
mickaelistria commentedon Oct 23, 2024
The IDE is already supposed to switch to dark theme when system is dark. So please provide details about your setup to hopefully reproduce this issue.
But on a side note, if you want the strongest possible integration with the system theme, you should simply disable theming (untick checkbox in the preference page and restart Eclipse IDE) and you'll get the widgets following the system theme as Eclipse doesn't override it.
Phillipus commentedon Oct 23, 2024
It does switch between light/dark with a fresh workspace. But once a theme has been set it won't.
If the
themeidsetting does not exist in.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefsthen the system light or dark theme is used. However, once a user sets the theme in preferencesthemeidis set to the id of the theme and this auto setting no longer works.In our RCP app we workaround this by deleting the
org.eclipse.e4.ui.css.swt.theme.prefsfile if the user chooses "Auto" which resets it.rombert commentedon Oct 24, 2024
Thanks for the info @mickaelistria ; been using Eclipse for around 20 years and always used theming. As @Phillipus says though, a theme was initially selected already in my installation so restarting after going to dark mode does not help. An explicit 'follow system theme' or similar would be very useful.
I am not sure if disabling theming is supposed to use OS colors in dark mode, but it does not.
I am using Gnome 47 in case that matters.
Phillipus commentedon Oct 24, 2024
As I said, all you have to do is delete the
<workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefsfile and it will follow the system theme.HeikoKlare commentedon Oct 25, 2024
We could think about making this properly configurable through preferences, e.g.:
Or there could just be an additional "virtual" option in the themes drop-down menu for enabling to follow the system theme.
Phillipus commentedon Oct 25, 2024
That's what I do. Selecting this deletes the
workspace>/.metadata/.plugins/org.eclipse.core.runtime/.settings/org.eclipse.e4.ui.css.swt.theme.prefsfile.HeikoKlare commentedon Oct 25, 2024
Sorry, I missed that comment. Sounds like a simple and sufficient approach to address this.
Phillipus commentedon Oct 25, 2024
More accurately it deletes the
themeidproperty in that file.mickaelistria commentedon Oct 25, 2024
There used to be a "System" theme: https://eclipse.dev/eclipse/news/4.18/platform.html#system-theme
But I removed it some time ago with 9328b2d as I realized default SWT behavior is supposed to follow the system GTK theme (eg Adwaita-dark) so basically this System theme was not so relevant to address the problem of following system colors.
Note that to make it work, the light/dark setting in gnome settings is not sufficient: the relevant setting is the "Appearance/Legacy Applications" one you can find in gnome-tweaks. I guess the current gnome settings is GTK4 only and is ignored as long as GTK3 is used by SWT; but there might still be some possible way to pass the right GTK3 theme according to GTK4 settings; but I don't think it will make it into SWT as the priority should be to just use directly GTK4.
sratz commentedon Oct 25, 2024
A System theme is a different concept (at least on Windows).
I think what we would want / need to have is the following:
eclipse.platform.ui/bundles/org.eclipse.e4.ui.css.swt.theme/src/org/eclipse/e4/ui/css/swt/internal/theme/ThemeEngine.java
Lines 602 to 613 in 5c9af91
However, simply doing that is not enough, because
To consider:
Technically, we would therefore need to:
isLightorisDarkand not derive it from the theme ID via some string comparison heuristics.rombert commentedon Oct 28, 2024
@Phillipus - that does not work for me, for whatever reason. I removeds the existing file, closed Eclipse, and started it again but I was still in light mode while the OS was in dark mode.
Regarding the wider discussion: I think ideally there would be a way to say 'follow System dark/light setting'. And yes, there may be multiple light and dark theme modes but for starters it would be great to be able to toggle between the build in dark and light modes through a virtual theme or checkbox in the preferences page.
Phillipus commentedon Oct 28, 2024
Which OS? Works for me on Windows and Mac (Linux might not work)
rombert commentedon Oct 28, 2024
Linux :-) Using Gnome 47.1 , to be more precise.
Phillipus commentedon Oct 28, 2024
In that case I'd say that the expected outcome will be...unpredictable.
Mailaender commentedon Nov 24, 2024
I can confirm that this follows the system theme on macOS, but it doesn't on Fedora KDE.
mickaelistria commentedon Nov 24, 2024
Does it work for plain SWT application in Fedora KDE ?
If plain SWT apps do follow the system colors, then it means that the Display.getSystemColor() do provide the right information; and we can then rely on those colors more reliably than on other settings in order to determine what is the closer theme to system.
Mailaender commentedon Nov 24, 2024
What I found out so far is
See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=564022 and my current workaround eclipse-chemclipse/chemclipse#1972.
Respect user light/dark preference when restoring nonexistent theme
Respect user light/dark preference when restoring nonexistent theme