Update theme engine
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -8,20 +8,24 @@
|
||||
let
|
||||
cfg = config.theme;
|
||||
|
||||
wallpaper = pkgs.copyPathToStore cfg.wallpaper;
|
||||
|
||||
init = pkgs.writeShellApplication {
|
||||
name = "theme-init";
|
||||
runtimeInputs = with pkgs; [ matugen ];
|
||||
text = ''
|
||||
[[ ! -d "${cfg.configDir}" ]] && mkdir -p "${cfg.configDir}"
|
||||
[[ ! -L "${cfg.configDir}"/wallpaper ]] && ln -sf "${wallpaper}" "${cfg.configDir}"/wallpaper
|
||||
[[ ! -f "${cfg.configDir}"/mode ]] && echo "${cfg.mode}" > "${cfg.configDir}"/mode
|
||||
mkdir -p "${cfg.configDir}"
|
||||
|
||||
matugen image "${cfg.configDir}/wallpaper" \
|
||||
--type scheme-${cfg.flavour} \
|
||||
--mode "$(cat "${cfg.configDir}/mode")" \
|
||||
--contrast ${builtins.toString cfg.contrast}
|
||||
[[ ! -L "${cfg.configDir}"/wallpaper ]] && [[ ! -f "${cfg.configDir}"/color ]] && echo "#000000" > "${cfg.configDir}"/color
|
||||
[[ ! -f "${cfg.configDir}"/mode ]] && echo "dark" > "${cfg.configDir}"/mode
|
||||
[[ ! -f "${cfg.configDir}"/flavor ]] && echo "tonal-spot" > "${cfg.configDir}"/flavor
|
||||
[[ ! -f "${cfg.configDir}"/contrast ]] && echo "0" > "${cfg.configDir}"/contrast
|
||||
|
||||
flags=(--mode "$(<"${cfg.configDir}/mode")" --type "scheme-$(<"${cfg.configDir}/flavor")" --contrast "$(<"${cfg.configDir}/contrast")")
|
||||
|
||||
if [[ -L "${cfg.configDir}"/wallpaper ]]; then
|
||||
matugen image "${cfg.configDir}"/wallpaper "''${flags[@]}"
|
||||
elif [[ -f "${cfg.configDir}"/color ]]; then
|
||||
matugen color hex "$(<"${cfg.configDir}"/color)" "''${flags[@]}"
|
||||
fi
|
||||
|
||||
${cfg.initExtraConfig}
|
||||
wait
|
||||
@@ -41,8 +45,6 @@ let
|
||||
runtimeInputs = with pkgs; [ coreutils ];
|
||||
runtimeEnv = {
|
||||
CONFIG = cfg.configDir;
|
||||
DEFAULT_WALLPAPER = wallpaper;
|
||||
DEFAULT_MODE = cfg.mode;
|
||||
INIT = lib.meta.getExe init;
|
||||
RELOAD = lib.meta.getExe reload;
|
||||
};
|
||||
@@ -63,11 +65,6 @@ in
|
||||
description = "The path to the theme config directory.";
|
||||
};
|
||||
|
||||
wallpaper = mkOption {
|
||||
type = path;
|
||||
description = "The path to the default wallpaper";
|
||||
};
|
||||
|
||||
pkg = mkOption {
|
||||
type = package;
|
||||
default = theme;
|
||||
@@ -120,36 +117,6 @@ in
|
||||
description = "Templates to fill with theme colors.";
|
||||
};
|
||||
|
||||
flavour = mkOption {
|
||||
type = enum [
|
||||
"content"
|
||||
"expressive"
|
||||
"fidelity"
|
||||
"fruit-salad"
|
||||
"monochrome"
|
||||
"neutral"
|
||||
"rainbow"
|
||||
"tonal-spot"
|
||||
];
|
||||
default = "tonal-spot";
|
||||
description = "The flavour of the theme.";
|
||||
};
|
||||
|
||||
mode = mkOption {
|
||||
type = enum [
|
||||
"dark"
|
||||
"light"
|
||||
];
|
||||
default = "dark";
|
||||
description = "The default mode of the theme.";
|
||||
};
|
||||
|
||||
contrast = mkOption {
|
||||
type = numbers.between (-1) 1;
|
||||
default = 0;
|
||||
description = "Use a modified contrast.";
|
||||
};
|
||||
|
||||
opacity = mkOption {
|
||||
type = numbers.between 0 1;
|
||||
default = 1;
|
||||
@@ -506,8 +473,6 @@ in
|
||||
percentageToHex = percentage: zeroPad (lib.trivial.toHexString (builtins.floor (percentage * 255)));
|
||||
in
|
||||
{
|
||||
flavour = cfg.flavour;
|
||||
contrast = builtins.toString cfg.contrast;
|
||||
radius = builtins.toString cfg.radius;
|
||||
padding = builtins.toString cfg.padding;
|
||||
padding_double = builtins.toString (cfg.padding * 2);
|
||||
|
Reference in New Issue
Block a user