From 8346e89b9f7ddef091f01974975e6a5c0047ba9e Mon Sep 17 00:00:00 2001 From: Nikolaos Karaolidis Date: Tue, 20 May 2025 09:54:36 +0100 Subject: [PATCH] Update theme engine Signed-off-by: Nikolaos Karaolidis --- .../common/configs/user/gui/swww/default.nix | 6 +---- .../common/configs/user/gui/theme/options.nix | 23 +++++++++++-------- hosts/common/configs/user/gui/theme/theme.sh | 6 ++--- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/hosts/common/configs/user/gui/swww/default.nix b/hosts/common/configs/user/gui/swww/default.nix index 4938fc2..bd2fc06 100644 --- a/hosts/common/configs/user/gui/swww/default.nix +++ b/hosts/common/configs/user/gui/swww/default.nix @@ -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 ''; } ); diff --git a/hosts/common/configs/user/gui/theme/options.nix b/hosts/common/configs/user/gui/theme/options.nix index d9a366b..0559e07 100644 --- a/hosts/common/configs/user/gui/theme/options.nix +++ b/hosts/common/configs/user/gui/theme/options.nix @@ -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; diff --git a/hosts/common/configs/user/gui/theme/theme.sh b/hosts/common/configs/user/gui/theme/theme.sh index 8c844d6..2cfb56f 100644 --- a/hosts/common/configs/user/gui/theme/theme.sh +++ b/hosts/common/configs/user/gui/theme/theme.sh @@ -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