danth / stylix

System-wide colorscheming and typography for NixOS
https://stylix.danth.me/
MIT License
1.16k stars 143 forks source link

Include pattern matching mechanism #211

Closed prescientmoon closed 9 months ago

prescientmoon commented 9 months ago

Some popular apps like discord do not yet have a stylix module. A hacky way to automate such themes is creating personal key-value map between base16 theme names and specific themes for said applications. Said maps can then be indexed with a function like

    get = themeMap:
      themeMap.${config.lib.stylix.scheme.scheme}
        or themeMap.default.${config.stylix.polarity or "dark"}
        or themeMap.default
        or (throw "Theme ${config.lib.stylix.scheme.scheme} not found in theme map!");

Example usage:

  home.packages = [ discocss ];
  xdg.configFile."discocss/custom.css".source = config.satellite.theming.get themeMap;

I've been using this approach for a while, and think others might find it useful. Just to be clear, stylix would not provide such modules/mappings, but would simply provide the pattern matching helper.

danth commented 9 months ago

Although this seems useful, I don't think it should be included in Stylix because it needs a lot of manual setup and only works for certain schemes. Perhaps you could publish it as a separate repository which works alongside?