Update theme engine

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2025-05-20 09:54:36 +01:00
parent ab1c9a4a78
commit 8346e89b9f
3 changed files with 17 additions and 18 deletions

View File

@@ -20,11 +20,7 @@ let
swww
];
text = ''
if [[ -L "${hmConfig.theme.configDir}"/wallpaper ]]; then
exec swww img "${hmConfig.theme.configDir}"/wallpaper
elif [[ -f "${hmConfig.theme.configDir}"/color ]]; then
exec swww clear "$(<"${hmConfig.theme.configDir}"/color)"
fi
exec swww img "${hmConfig.theme.configDir}"/wallpaper
'';
}
);

View File

@@ -10,22 +10,22 @@ let
init = pkgs.writeShellApplication {
name = "theme-init";
runtimeInputs = with pkgs; [ matugen ];
runtimeInputs = with pkgs; [
matugen
imagemagick
];
text = ''
mkdir -p "${cfg.configDir}"
[[ ! -L "${cfg.configDir}"/wallpaper ]] && [[ ! -f "${cfg.configDir}"/color ]] && echo "#000000" > "${cfg.configDir}"/color
[[ ! -f "${cfg.configDir}"/wallpaper ]] && magick -size 1x1 xc:"#000000" png:"${cfg.configDir}"/wallpaper
[[ ! -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
matugen image "${cfg.configDir}"/wallpaper \
--mode "$(<"${cfg.configDir}/mode")" \
--type "scheme-$(<"${cfg.configDir}/flavor")" \
--contrast "$(<"${cfg.configDir}/contrast")"
${cfg.initExtraConfig}
wait
@@ -42,7 +42,10 @@ let
theme = pkgs.writeShellApplication {
name = "theme";
runtimeInputs = with pkgs; [ coreutils ];
runtimeInputs = with pkgs; [
coreutils
imagemagick
];
runtimeEnv = {
CONFIG = cfg.configDir;
INIT = lib.meta.getExe init;

View File

@@ -16,7 +16,7 @@ set_wallpaper() {
}
set_color() {
local re='^#?([A-Fa-f0-9]{6})$'
local re='^#([A-Fa-f0-9]{6})$'
if [[ "$1" =~ $re ]]; then
color="$1"
else
@@ -63,8 +63,8 @@ usage() {
}
finish() {
[[ -n "$wallpaper" ]] && rm -f "$CONFIG"/color && ln -sf "$wallpaper" "$CONFIG"/wallpaper
[[ -n "$color" ]] && rm -f "$CONFIG"/wallpaper && echo "$color" > "$CONFIG"/color
[[ -n "$wallpaper" ]] && rm -f "$CONFIG"/wallpaper && ln -sf "$wallpaper" "$CONFIG"/wallpaper
[[ -n "$color" ]] && rm -f "$CONFIG"/wallpaper && magick -size 1x1 xc:"$color" png:"$CONFIG"/wallpaper
[[ -n "$mode" ]] && echo "$mode" > "$CONFIG"/mode
[[ -n "$flavor" ]] && echo "$flavor" > "$CONFIG"/flavor
[[ -n "$contrast" ]] && echo "$contrast" > "$CONFIG"/contrast