Coder Social home page Coder Social logo

iniox / matugen Goto Github PK

View Code? Open in Web Editor NEW
175.0 3.0 7.0 8.71 MB

A material you color generation tool

License: GNU General Public License v2.0

Nix 3.52% Rust 96.48%
linux color-scheme color-scheme-generator colorscheme-generator macos material-design material-design-3 windows material-you material-you-3

matugen's Introduction

A cross-platform material you color generation tool

Description

Features

  • Generate/Export Material You Color Palette:
    • Generate a Material You color palette either from an image or a color
    • Output the generated palette as JSON to stdout, or use keywords inside templates that get exported as files
  • Keyword Filters:
    • Use filters to change values of the keywords, like changing lightness for colors and manipulating strings with replace, to_upper, to_lower and set_lightness
  • Custom Keywords/Colors:
    • Define your own custom keywords or colors you would like to be harmonized inside the config file, that you can then use in templates
  • Palette Customization:
    • Customize the contrast and scheme type for the palette
  • Restart Apps/Change Wallpaper:
    • Restart supported apps and set the wallpaper on Windows, MacOS, Linux and NetBSD

If you would like to learn more about the features and configuration, read the wiki here.

About Material Design 3

Material Design 3 offers a new color system that allows for more flexible and dynamic use of color. The new system includes a wider range of colors, as well as a range of tints and shades that can be used to create subtle variations in color.

Other projects

  • Mitsugen - For gnome-shell, based on the old version of Matugen
  • pywal - More color generation backends, default theme files.
  • wpgtk - Like pywal, but with a gui and more features.

Supported platforms

  • Windows
  • Linux
  • MacOS
  • NetBSD

Installation

Cargo AUR Version

Click to expand
cargo install matugen

Arch Cargo Version

Click to expand

Using your favourite AUR helper:

yay install matugen-bin

NixOS NixOS Version

Click to expand

Add matugen to your flake inputs:

inputs = {
  matugen = {
    url = "github:/InioX/Matugen";
    # If you need a specific version:
    ref = "refs/tags/matugen-v0.10.0"
  };
  # ...
};

Then you can add it to your packages:

let
  system = "x86_64-linux";
in {
  environment.systemPackages = with pkgs; [    
    # ...
    inputs.matugen.packages.${system}.default
  ];
}

This flake also provides a NixOS/Home Manager module, which can be imported by adding this in your configuration:

{pkgs, inputs, ...}: {
  imports = [
    inputs.matugen.nixosModules.default
  ];

  # ...
}

The module does NOT automatically symlink the files. For an example of using this module with Home Manager, see #28

Option details can be found by reading the module. A search.nixos.org-like option viewer is planned.

NetBSD pkgsrc current package

Click to expand
pkgin install matugen

or, if you prefer to build it from source

cd /usr/pkgsrc/graphics/matugen
make install

Acknowledgements

matugen's People

Contributors

0323pin avatar alphaqu avatar ehllay avatar fufexan avatar github-actions[bot] avatar iniox avatar misterio77 avatar nikclayton avatar posaydone avatar theaninova avatar yesterday17 avatar zmrl010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

matugen's Issues

warnings while building 0.10.0

Updating the NetBSD package to the latest 0.10.0
Rust-1.71.1

FI,

Compiling ini-material-color-utilities-rs v0.4.0 (/usr/pkgsrc/wip/matugen/work/matugen-matugen-v0.10.0/material-color-utilities-rs)
warning: unused import: `linearized`
 --> material-color-utilities-rs/src/htc/cam16.rs:4:41
  |
4 | use crate::util::color::{argb_from_xyz, linearized, xyz_from_argb};
  |                                         ^^^^^^^^^^
  |
  = note: `#[warn(unused_imports)]` on by default

   Compiling resolve-path v0.1.0
warning: associated function `new` is never used
   --> material-color-utilities-rs/src/htc/cam16.rs:119:8
    |
34  | impl Cam16 {
    | ---------- associated function in this implementation
...
119 |     fn new(
    |        ^^^
    |
    = note: `#[warn(dead_code)]` on by default

   Compiling directories v5.0.1
   Compiling toml v0.7.3
   Compiling pretty_env_logger v0.4.0
   Compiling colorsys v0.6.7
warning: `ini-material-color-utilities-rs` (lib) generated 2 warnings (run `cargo fix --lib -p ini-material-color-utilities-rs` to apply 1 suggestion)

Enquote Failure for Mac Installation

Hello. I am on a macOS, and I attempted to update my version of matugen by reinstalling it via cargo. However, I encountered the following error message while doing so:

error[E0433]: failed to resolve: use of undeclared crate or module `enquote`
 --> /Users/kl/.cargo/registry/src/index.crates.io-6f17d22bba15001f/matugen-1.2.1/src/wallpaper/macos.rs:9:9
  |
9 |         enquote::enquote('"', path),
  |         ^^^^^^^ use of undeclared crate or module `enquote`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `matugen` (bin "matugen") due to previous error
error: failed to compile `matugen v1.2.1`, intermediate artifacts can be found at `/var/folders/gv/ff_6l8ys0mzb8bbrg2s7s5f00000gn/T/cargo-install6q2jJi`.
To reuse those artifacts with a future compilation, set the environment variable `CARGO_TARGET_DIR` to that path.

Thank you!

Harmonized Colors Contrast

I really love the harmonized color feature in concept, but it does not seem to work well with dynamic theming (using dark and light theme and different source colors with the same config file).

For context, what I'd ideally want is a solution to get very rough hues for a few colors (usually the terminal colors) and have them adjusted to look nice with the theme color while also maintaining good contrast with the surface color like accent colors do.

The harmonization seems to preserve the source colors a little too well, and ends up with variants that may work well in dark theme or light theme, but almost never in both.

(If you want to know why I want custom colors in the first place, I really like my syntax highlighting to be generally the same hues. Strings green, numbers blue, etc)

Input #00ff00

image
image

Input #ff0000

image
image

There's almost zero adjustment between dark and light, and looks to me like they only get shifted along the hue axis. This unfortunately means that they are more or less unusable for the purpose of readable content (as opposed to art against a background).

Ideally I'd like a solution where I could add static colors as per md3 spec, and get a full set of these.

Why

You may need to apply static colors in your app for brand expression or to communicate semantic meaning, like a green success state. By defining these colors using the Material system, they'll work with existing Material colors and support features like dynamic color and user-controlled contrast.

How

Use the Material Theme Builder to input a custom color. Material will return four color roles derived from that reference color. The main color, on-main color, container color, and on-container color all follow the conventions of the accent colors in the main scheme, and can be applied to your UI according to the same relationships. See map or remap colors on UI elements for more information.

image

[config.static_colors]
red = "#ff0000"
some_prop = {{colors.red.default.hex}}
some_prop = {{colors.on_red.default.hex}}
some_prop = {{colors.red_container.default.hex}}
some_prop = {{colors.red_90.default.hex}} #maybe? bonus addition

Problem with example config

Hi there, was trying out this tool and I think the example config is broken as I try to run it and I get the following error:

matugen image ~/Projects/dotfiles/ags/assets/space.jpg

Error: 
   0: render error

         --> name1:28:36
          |
       28 | @define-color source_color {{colors.source_color.default.hex}};;
          |                                    ^^^^^^^^^^^^^
          |
          = reason: not found in map
   0: 
   1: render error: not found in map

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

Suggestion: nixOS module for configuration file instead of one-time usage

I want to imperatively select my wallpaper (with rofi). I figured that the nixOS module would act like most home-manager modules and simply let me configure the matugen.toml file instead of launching the command once with the supplied args.

Is there any chance we'll get a module that can write the configuration file instead? Nix modules for toml files are relatively easy to write. For reference take a look at the starship hm-module.

Error compiling with NixOS flake

I am trying to install matugen using flake.nix. I followed the instructions in the readme and got the following error:

error: builder for '/nix/store/i5g10yffkx7afalsg0dwkblr4xbnqrld-matugen-2.2.0.drv' failed with exit code 101;
       last 20 log lines:
       >   |
       > 1 | pub use core::CorePalette;
       >   |         ^^^^ ambiguous name
       >   |
       >   = note: ambiguous because of multiple potential import sources
       >   = note: `core` could refer to a built-in crate
       >   = help: use `::core` to refer to this crate unambiguously
       > note: `core` could also refer to the module defined here
       >  --> /build/cargo-vendor-dir/material-colors-0.3.1/src/palette/mod.rs:4:1
       >   |
       > 4 | mod core;
       >   | ^^^^^^^^^
       >   = help: use `self::core` to refer to this module unambiguously
       >
       >    Compiling paris-log v1.0.2
       >    Compiling clap v4.4.11
       >    Compiling resolve-path v0.1.0
       > For more information about this error, try `rustc --explain E0659`.
       > error: could not compile `material-colors` (lib) due to previous error

Prefix does not work

My config: File

[templates.kitty]
input_path = '/.config/matugen/default/kitty.conf'
output_path = '
/.config/kitty/colors.conf'

[config]
reload_apps = true
set_wallpaper = false

[config.reload_apps_list]
kitty = true
gtk_theme = true

When generating new color scheme, the prefixes is not replaced, my final file:

cursor #f0f0f0
cursor_text_color #ffffff

@{surface}

i need use

{{colors.on_surface.default.hex}}

[Question] How to use nixos module

Hi,
I've tried to figure out, how to use matugen home-manager module, but to no avail. I've created config file, with contents described below, and imported in my home.nix and it just don't work. Maybe I'm misunderstanding how to use it?

{inputs, ...}: {
  imports = [
    inputs.matugen.nixosModules.default
  ];

  programs.matugen = {
    enable = true;
    variant = "dark";
    jsonFormat = "hex";
    palette = "default";

    templates = {
      ags = {
        input_path = "./templates/ags.scss";
        output_path = "~/.config/ags/scss/colors.scss";
      };

      kittty = {
        input_path = "./templates/kitty.conf";
        output_path = "~/.config/kitty/colors.conf";
      };

      gtk = {
        input_path = "./templates/gtk.css";
        output_path = "~/.config/gtk-4.0/gtk.css";
      };

      hypr = {
        input_path = "./templates/hypr.conf";
        output_path = "~/.config/hypr/colors.conf";
      };

      yazi = {
        input_path = "./templates/yazi.toml";
        output_path = "~/.config/yazi/theme.toml";
      };
    };
  };
}

Application crashed

Hi, I got this error when running

matugen image imagepath --json hex

here's the output

The application panicked (crashed).
Message:  attempt to divide by zero
Location: /home/ezerinz/.cargo/registry/src/index.crates.io-6f17d22bba15001f/material-colors-0.2.1/src/quantize/quantizer_wu.rs:274

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.

the output with RUST_BACKTRACE=fuill :


  ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ BACKTRACE ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                                ⋮ 6 frames hidden ⋮
   7: core::panicking::panic::h3a6ee9ab3bd88b9b
      at <unknown source file>:<unknown line>
   8: material_colors::quantize::quantizer_wu::QuantizerWu::variance::hc92ce0aabe322924
      at <unknown source file>:<unknown line>
   9: material_colors::quantize::quantizer_wu::QuantizerWu::create_boxes::hdd1f6b13f7e872ca
      at <unknown source file>:<unknown line>
  10: <material_colors::quantize::quantizer_wu::QuantizerWu as material_colors::quantize::quantizer::Quantizer>::quantize::h8f0c5af9e90244aa
      at <unknown source file>:<unknown line>
  11: <material_colors::quantize::quantizer_celebi::QuantizerCelebi as material_colors::quantize::quantizer::Quantizer>::quantize::h4d0b10b9de5a1f2d
      at <unknown source file>:<unknown line>
  12: material_colors::utils::image::ImageReader::extract_color::h3482ae9b646f0042
      at <unknown source file>:<unknown line>
  13: matugen::util::color::get_source_color::h7b2d4074c4118660
      at <unknown source file>:<unknown line>
  14: matugen::main::h2a7c26fee03efcd9
      at <unknown source file>:<unknown line>
  15: std::sys_common::backtrace::__rust_begin_short_backtrace::ha51465a398fe07a2
      at <unknown source file>:<unknown line>
  16: std::rt::lang_start::{{closure}}::h122fa072e691f758
      at <unknown source file>:<unknown line>
  17: std::rt::lang_start_internal::h24e0e4b30b186ec6
      at <unknown source file>:<unknown line>
  18: main<unknown>
      at <unknown source file>:<unknown line>
  19: __libc_start_main<unknown>
      at <unknown source file>:<unknown line>
  20: _start<unknown>
      at <unknown source file>:<unknown line>

Use an alternative to regex inside templates

The code in template.rs file is pretty messy, it needs a rewrite.

Matugen should replace the regex library with a template engine, so it's easier to add more color formats (like red, green, blue, saruration, hue, and lightness as separate formats), while also making the code more readable and easier to maintain.

Replacing the engine would also make it so you can add custom user defined keywords.

Some colors don't match image properly

Thank you very much for this project! I should clarify, this very much could be a non-issue or a material-color-utilities-rs problem and not a Matugen one; please let me know if so.

I was trying to use Matugen to create a GTK3/4 theme based on my wallpaper (the exact same thing that Gradience can do but I wanted to use Matugen to be able to theme many different things). After setting the wallpaper and rebuilding, I noticed the colors didn't match up at all. My apps were a bright blue color, while the wallpaper contains only a small amount of very muted blue/teal:
alena-aenami-budapest

After a while of debugging, I believe I've narrowed the issue down to either Matugen or material-color-utilities-rs. Here is what the official Material Theme Builder produces (very understandably):
20231222_22h01m22s_grim
Lastly, heres a comparison of the JSON output of Matugen (matugen image Downloads/alena-aenami-budapest.jpg --json hex | jq) vs material_color_utilities_python (using the exact same python script that Gradience uses) vs the theme builder, all on dark mode:
20231222_22h15m17s_grim
IMO, Matugen's output does not follow the image. However, it's interesting that some of the colors seem to match the other two outputs almost exactly (eg. "error").

I should also mention that I tried this with two other wallpapers as well; Matugen did better slightly better following the other two, but seemed to sway extra towards blue comparatively (this could probably use more testing).

Please let me know if you have any ideas what might be causing this, and if you think I should instead report it to material-color-utilities-rs!

Mode in config seems to be ignored

I have a script which passes --mode light or dark depending on time of day, but i like my Waybar being always dark, so for the Waybar template i set mode = "Dark" in the Matugen config, but this seems to make no difference

AUR package

Any chance of creating an AUR package? Thank you.

Additional Color Schemes

Hi!

As requested, I'm making a new issue/feature request for adding other non monotone color schemes in different schema such as

  1. Triadic
  2. Tetradic
  3. Adjacent
  4. Complimentary

my preference would be Triadic or Adjacent since they already fit into the three-color format used by the monet engine.

Best,
KSH

AMOLED Dark mode

Hi!

it would be really cool there were an extra dark mode ala AMOLED black. Not sure where to start with that though.

color exported to css file different from generated

Hi!

The colors exported to the css file via template seems to have the green and blue channels swapped.

The error seems to be here in template.rs

regexvec.push(ColorPatterns {
hex: ColorPattern {
pattern: Regex::new(&format!(r#"{prefix}{{{field}}}"#).to_string())?,
replacement: format_argb_as_rgb([color.alpha, color.red, color.blue, color.green]),
},
hex_stripped: ColorPattern {
pattern: Regex::new(&format!(r#"{prefix}{{{field}.strip}}"#).to_string())?,
replacement: format_argb_as_rgb([color.alpha, color.red, color.blue, color.green])
[1..]
.to_string(),
},
rgb: ColorPattern {
pattern: Regex::new(&format!(r#"{prefix}{{{field}.rgb}}"#).to_string())?,
replacement: format!("rgb({:?}, {:?}, {:?})", color.red, color.blue, color.green),
},
rgba: ColorPattern {
pattern: Regex::new(&format!(r#"{prefix}{{{field}.rgba}}"#).to_string())?,
replacement: format!(
"rgba({:?}, {:?}, {:?}, {:?})",
color.red, color.green, color.blue, color.alpha
),
},
});

where instead of color.red, coilor.green, color.blue ; we have color.red, color.blue, color.green

gtk-3.0 and 4.0

hi...

first. this is a great project and i'm happy that i found it.
i managed to theme my hyprland, waybar, cava, kitty, astrovim, wofi and mako (notification daemon)

gut what i did not understand was the gtk theme.
tryed to figure it out also with your dotfiles (nixos tree).

it would be great if you could send an short tutorial something simular.
(also checked mitsugen)

Thanks,

Question: Is it possible to "lock-in" a color?

I'd like to generate a palette with some predefined colors. For example, have the primary and secondary colors locked-in, and generate the rest of the palette around those. Is this possible?

generated colors mixed in templates

for example i create an wofi styles.css
the primary color from a wallpaper is shown by matugen as
#b7c8e1 but the color in the generated css is
#b7e1c8

so color.green and color.blue is switched

also if i use primary.rgb

btw .hex is not working in templates.

template.rs line 155, 159 & 165
replacement: format!("rgb({:?}, {:?}, {:?})", color.red, color.blue, color.green)

red green blue ;)

Cargo Mac Installed Failed

Hi! I saw that this project supports macOS, and I wanted to try it out. I know that reloading applications and setting the wallpaper is only supported on Linux platforms, but I wanted to see the colors it could generate from images. When attempting to install this on macOS via cargo, I get the following error:

error[E0432]: unresolved imports util::reload::reload_apps_linux, util::wallpaper::set_wallaper

Is there a way to skip these utils since they won't work on macOS at all? If not, are there alternate ways to install matugen on a macOS? Thank you!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.