-
-
Notifications
You must be signed in to change notification settings - Fork 300
feat: add theme modality support for light/dark themes #1899
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
base: master
Are you sure you want to change the base?
Conversation
Add support for configuring separate light and dark themes that can be used by applications supporting automatic theme switching. This includes: - New theme.light and theme.dark configuration options - defaultTheme option to control fallback for single-theme apps - Full backward compatibility with existing configurations - Ghostty integration with automatic light/dark theme switching - Documentation for theme modality configuration and migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know if this is something the project is looking to adopt
Yes, adding polarity switching is on the roadmap, although your proposal is not a general automatic solution:
- (7) Support automatic polarity switch based on sunset and sunrise
-- #534
Related #447
Consider taking a look at the following existing discussions:
Also, #892 might simplify stylix.polarity by removing the non-decisive "either" variant.
- New theme.light and theme.dark configuration options
The stylix.theme.{dark,light}.icons.package top-level namespace seems to be better than the previously proposed stylix.theme.icons.{dark,light}.package API:
stylix.icons = { dark = { name = "<DARK_THEME>"; package = pkgs."<DARK_PACKAGE>"; }; enable = true; light = { name = "<LIGHT_THEME>"; package = pkgs."<LIGHT_PACKAGE>"; }; };
As mentioned in #892 (comment), stylix.theme is too broad and should be replaced with something like stylix.colors.
- defaultTheme option to control fallback for single-theme apps
Would everyone not just treat this exactly like stylix.polarity, making this option redundant and confusing?
- Full backward compatibility with existing configurations
Thanks for going the extra mile of making this backward compatible, but since the following roadmap tasks are likely already going to introduce slight breaking changes, it might be better to accept breaking changes in order to keep the interface and implementation simple:
- (4) Extend and standardize color scheme
[...]- (6) Implement slideshow with post-processing capabilities
[...]- (7) Support automatic polarity switch based on sunset and sunrise
-- #534
However, the extent of the breaking change can be substantially reduced by aliasing the existing options into stylix.theme.dark with lib.mkRenamedOptionModuleWith.
- Documentation for theme modality configuration and migration
Instead of adding a new documentation page, the existing documentation should be appropriately updated. I am aware this is a PoC, but this should eventually be resolved.
| # If we have different light and dark themes, configure both | ||
| # Ghostty supports auto-switching, so we always provide both themes | ||
| (lib.mkIf hasDifferentThemes { | ||
| settings.theme = "dark:stylix-dark,light:stylix-light"; | ||
| themes = { | ||
| stylix-dark = makeTheme darkColors; | ||
| stylix-light = makeTheme lightColors; | ||
| }; | ||
| }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Ghostty integration with automatic light/dark theme switching
AFAICT, this is not automatically switching polarity. Do you mean that this exposes theme variants to the application that can at run time be manually selected? In this case, this would be a subset of #447, except that the theme variants are not exposed to the application, although this would be mostly irrelevant in that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For applications that support xdg-desktop-portal-gtk theme, meaning they accept a config that supports switching between two themes.
For any application that needs to toggle between two themes, they'd need to integrate via darkman scripts. We could likely configure these, assuming we're happy to loop in darkman.
Other applications would fallback on the defaultTheme/polarity.
until extended polarity support is added to stylix ref: * nix-community/stylix#447 * nix-community/stylix#1899
I don't know if this is something the project is looking to adopt, but I forked and made this work for Ghostty for my own experiment and plan to add support for more modules.
Sharing for feedback and to hopefully upstream.
Related #447
Add support for configuring separate light and dark themes that can be used by applications supporting automatic theme switching. This includes: