Misterio77 / nix-colors

Modules and schemes to make theming with Nix awesome.
GNU General Public License v3.0
480 stars 41 forks source link

hex to dec help #60

Open aspauldingcode opened 1 month ago

aspauldingcode commented 1 month ago

How can I do what I'm trying to do?

system.defaults.CustomUserPreferences = {
  NSGlobalDomain = {
    AppleHighlightColor = let
      # Example hex color code
      hexColor = "FF00FF";  # Replace with your hex color (without #)

      # Manually set RGB values
      rgbValues = [
        255
        0
        255
      ];

      # Normalize RGB values to 0-1 range
      r = builtins.elemAt rgbValues 0 / 255.0;
      g = builtins.elemAt rgbValues 1 / 255.0;
      b = builtins.elemAt rgbValues 2 / 255.0;
    in "${toString r} ${toString g} ${toString b} Other";
  };
};

I am expecting the hex to decimal to format as the following string: "1.0 0.5 1.0 Other";

As r, g, b, "Other" string values.

so that I can basically do an r g b ranging from 0.0 to 1.0 custom color for macOS accent using nix darwin macos defaults configuration.

aspauldingcode commented 1 month ago

I found this https://discourse.nixos.org/t/convert-hexadecimal-color-triplet-to-decimal/31633/2

and I'm not sure what to do with it.

I also found this https://github.com/Misterio77/nix-colors/blob/main/lib/core/tests/conversions.nix

and https://github.com/Misterio77/nix-colors/blob/main/lib/core/conversions.nix

in the code idk what it is or how to use it...