diff --git a/home/modules/color/applyColors.py b/home/modules/color/applyColors.py new file mode 100644 index 00000000..7f8461ec --- /dev/null +++ b/home/modules/color/applyColors.py @@ -0,0 +1,16 @@ +import fileinput + +colors: dict[str, str] +# colors: dict[str, str] = { +# "rosewater": "f5e0dc", +# "flamingo": "f2cdcd", +# } + + +def applyColorToLine(line: str) -> None: + print(f"{line} # piped") + + +# Apply transformation to every line from stdin +for line in fileinput.input(): + applyColorToLine(line) diff --git a/home/modules/color/default.nix b/home/modules/color/default.nix index eb3b8e61..5705e04d 100644 --- a/home/modules/color/default.nix +++ b/home/modules/color/default.nix @@ -2,6 +2,7 @@ config, lib, mylib, + pkgs, ... }: let inherit (config.modules) color; @@ -20,8 +21,29 @@ in { mkRgbColorAssignment = defs: key: {${key} = mylib.color.hexToRGB defs.${key};}; mkRgbStringColorAssignment = defs: key: {${key} = mylib.color.hexToRGBString "," defs.${key};}; in { - # This module sets its own options - # to the values specified in a colorscheme file. + # Helper script that processes a visual mode selection and replaces + # referenced colors in-place with their counterparts in this module. + # Usage: '<,'>!applyColors + home.packages = let + applyColors = let + mkPythonColorDef = name: value: " '${name}': '${value}',"; + in + pkgs.writers.writePython3Bin + "applyColors" + ( + builtins.concatStringsSep "\n" [ + "colors: dict[str, str] = {" + (config.modules.color.hex.dark + |> builtins.mapAttrs mkPythonColorDef + |> builtins.attrValues + |> builtins.concatStringsSep "\n") + "}" + (builtins.readFile ./applyColors.py) + ] + ); + in [applyColors]; + + # This module sets its own options to the values specified in a colorscheme file. # TODO: This is fucking stupid. Add an option to set a colorscheme, # then provide a single hex/rgb/rgbString set, not this light/dark shit. modules.color = {