diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-22 17:49:44 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-04-22 17:49:44 +1000 |
| commit | ce6fdf0ab9e113f02fd41744e2176d5c3b538c48 (patch) | |
| tree | 1f416c5025ba54de8544818d9da6e5d771b7749f /scheme/gen-scheme.fish | |
| parent | install: spicetify install marketplace (diff) | |
| download | caelestia-cli-ce6fdf0ab9e113f02fd41744e2176d5c3b538c48.tar.gz caelestia-cli-ce6fdf0ab9e113f02fd41744e2176d5c3b538c48.tar.bz2 caelestia-cli-ce6fdf0ab9e113f02fd41744e2176d5c3b538c48.zip | |
feat: up to 3 options for dynamic scheme
Have up to 3 options for base colour for dynamic scheme
Variants moved to new command
Also remove parallel dependency
Diffstat (limited to 'scheme/gen-scheme.fish')
| -rwxr-xr-x | scheme/gen-scheme.fish | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/scheme/gen-scheme.fish b/scheme/gen-scheme.fish index c034980..488ee27 100755 --- a/scheme/gen-scheme.fish +++ b/scheme/gen-scheme.fish @@ -5,30 +5,29 @@ set -l src (dirname (status filename)) . $src/../util.fish test -f "$argv[1]" && set -l img (realpath "$argv[1]") || set -l img $C_STATE/wallpaper/thumbnail.jpg -contains -- "$argv[2]" light dark && set -l theme $argv[2] || set -l theme dark set -l variants vibrant tonalspot expressive fidelity fruitsalad rainbow neutral content monochrome -set -l hash (sha1sum $img | cut -d ' ' -f 1) +contains -- "$argv[2]" $variants && set -l variant $argv[2] || set -l variant (cat $C_STATE/scheme/current-variant.txt 2> /dev/null) +contains -- "$variant" $variants || set -l variant tonalspot -# Cache schemes -mkdir -p $C_CACHE/schemes -set -l dirty_variants -if test -d $C_CACHE/schemes/$hash - for variant in $variants - test -f $C_CACHE/schemes/$hash/$variant/$theme.txt || set -a dirty_variants $variant - end -else - set dirty_variants $variants -end +set -l hash (sha1sum $img | cut -d ' ' -f 1) -if test -n "$dirty_variants" - # Generate schemes for variants that need it +# Cache scheme +if ! test -d $C_CACHE/schemes/$hash/$variant set -l colours ($src/score.py $img) - parallel "mkdir -p $C_CACHE/schemes/$hash/{} && $src/autoadjust.py $theme {} '$colours' | head -c -1 > $C_CACHE/schemes/$hash/{}/$theme.txt" ::: $dirty_variants + $src/autoadjust.py dark $variant $colours $C_CACHE/schemes/$hash + $src/autoadjust.py light $variant $colours $C_CACHE/schemes/$hash end -# Copy schemes from cache -for variant in $variants - mkdir -p $src/../data/schemes/dynamic/$variant - cp $C_CACHE/schemes/$hash/$variant/$theme.txt $src/../data/schemes/dynamic/$variant/$theme.txt +# Copy scheme from cache +rm -rf $src/../data/schemes/dynamic +cp -r $C_CACHE/schemes/$hash/$variant $src/../data/schemes/dynamic + +# Update if current +set -l variant (string match -gr 'dynamic-(.*)' (cat $C_STATE/scheme/current-name.txt 2> /dev/null)) +if test -n "$variant" + # If variant doesn't exist, use default + test -d $src/../data/schemes/dynamic/$variant || set -l variant default + # Apply scheme + $src/main.fish dynamic $variant $MODE > /dev/null end |