-
-
Notifications
You must be signed in to change notification settings - Fork 185
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
treewide: adapt icon theme colors #157
base: master
Are you sure you want to change the base?
Conversation
if were going to add a new package to stylix we might want to reorganise were it and the palate generator are place, ie putting them both into ./pkgs or something |
modules/icon-theme/hm.nix
Outdated
}; | ||
|
||
config = cfg.enable { | ||
home-manager.users.${config.modules.user.name} = { |
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.
This shouldn't be here, Stylix will import the module directly into Home Manager.
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.
It was meant to be mkIf cfg.enable. Should I remove it completely?
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 meant the home-manager.users.${config.modules.user.name}
part. The way the modules are loaded means that anything in hm.nix
is already inside Home Manager, so you can remove that line.
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.
Oh right, I based this off a module that lives in my own nix flake, so I must have forgotten to change it
modules/icon-theme/hm.nix
Outdated
iconTheme = lib.mkMerge [ | ||
{ | ||
name = cfg.name; | ||
} | ||
|
||
(lib.mkIf (!cfg.adjustColorScheme.enable) { | ||
package = cfg.package; | ||
}) | ||
(lib.mkIf (cfg.adjustColorScheme.enable) { |
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 think it's fine to use a normal if statement here rather than mkMerge
.
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.
This just me gives me an error. I'm stilla little new to nix, so not sure how to do it
iconTheme = {
name = cfg.name;
(lib.mkIf (!cfg.recolor.enable) {
....
})
(lib.mkIf (cfg.recolor.enable) {
...
});
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.
Something like
iconTheme = {
name = cfg.name;
package =
if cfg.recolor.enable
then ...
else ...;
};
modules/icon-theme/hm.nix
Outdated
colors = lib.mkOption { | ||
description = "The color to use when mode is set to color"; | ||
type = lib.types.listOf (lib.types.str); | ||
default = | ||
if cfg.adjustColorScheme.mode == "color" then | ||
config.lib.stylix.colors.withHashtag.base09 | ||
else if cfg.adjustColorScheme.mode == "color-from-palette" then | ||
with config.lib.stylix.colors.withHashtag; [ | ||
base08 | ||
base09 | ||
base0A | ||
base0B | ||
base0C | ||
base0D | ||
base0E | ||
base0F | ||
] | ||
else | ||
with config.lib.stylix.colors.withHashtag; [ | ||
base00 | ||
base01 | ||
base02 | ||
base03 | ||
base04 | ||
base05 | ||
base06 | ||
base07 | ||
base08 | ||
base09 | ||
base0A | ||
base0B | ||
base0C | ||
base0D | ||
base0E | ||
base0F | ||
]; |
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.
Does this need to be an option? It looks more like an implementation detail.
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 added it in 32da08c. Before that commit, it was only possible to customize the color when the mode was set to "color" which just sets all the icons to a single color. I thought it the other modes should be customizable as well, as someone might want to use different colors. Maybe for some color-schemes only some colors work well.
Co-authored-by: Daniel Thwaites <[email protected]>
Co-authored-by: Daniel Thwaites <[email protected]>
Co-authored-by: Daniel Thwaites <[email protected]>
I'm wondering how we should add support for recoloring the wallpaper as well? @danth |
After #102 is finished we should be able to add that as a function which takes in an image and a color scheme, and outputs the recoloured wallpaper. |
@danth What about recoloring the parent icon themes? For example in the "Numix Circle" theme the folder icons come from the parent "Numix" theme and those don't get recolored and look out of place. Surely there's a way? |
I'm not too familiar with how icon themes are packaged in NixOS. If the parent theme is a separate package then we would need to override it from there. Does the Numix Circle theme depend on Numix or do you install them separately? |
@danth https://github.com/NixOS/nixpkgs/blob/nixos-23.05/pkgs/data/icons/numix-icon-theme-circle/default.nix#L40 |
If they're the only thing in |
Could you help me with that? I'm not quite sure how |
Any example configs on how to use this branch? The icon theme colors look great. |
@donovanglover stylix.targets.iconTheme = {
enable = true;
name = "Zafiro-icons-Dark";
package = pkgs.zafiro-icons;
recolor = {
enable = true;
mode = "palette";
colors = with config.lib.stylix.colors.withHashtag; [
base08
base09
base0A
base0B
base0C
base0D
base0E
base0F
];
smooth = false;
};
};
}; |
Really useful for colorschemes that don't work well with some icons, causing poor contrast
d1a69f2
to
d4a5ca7
Compare
* Use str_float type rather than checking each arguement is not null and conveting to float * Update the way color modifications work. Now, saturation/light can be changed for both accent and foreground colors * Currently color modifications only work for SVGs as it's too slow for images
* It was checking for the new color, rather than the old color for detecting if it's an accent/foreground color * There's no need to check for the distance between the color and white, checking the light value is enough * Update the foregroundThreshold value and default for the new method * Now using custom saturation/light values for images will also work, checking for the distance for each color in each image is too slow so couldn't be enabled before
@danth I added lots of options to better allow for adjusting the output, which helps icons that previously had very poor contrast when they got recolored. You can look at the new pics for examples. |
c88358b
to
2c3993d
Compare
2c3993d
to
9b1fbed
Compare
When rebased on master, this branch causes an infinite recursion with my config:
|
Got around to trying this out and it's pretty cool. Lots of options to play around with but would be great if it produced better results by default. Not all themes will have |
Anyone interested in this may also want to check #370, where I implemented this manually for parts of the Adwaita icon theme (the default in GNOME) |
* Switched colormath to basic_colormath as the upstream project is using it now, should be faster too * Using the previous color lightness to prevent icons from ending up as a big circle of indistinguishable colors * Removed unused code
@donovanglover I made some changes, it should not produce circles of indistinguishable colors anymore (or so I hope) |
For reference:
|
I've been using this in my personal configuration for a bit, but not sure if you guys will be interested in this. The script is a modified and stripped down version of color-manager.
One issue that I'm having is with parent themes. They should always be accessible in propagatedbuildinputs, but I'm unsure how to dynamically adjust them. Additionally, this script could potentially be expanded to recolor wallpapers, but that would require some adjustments as well.
Examples:

Gruvbox:
Nord:
