scheme: better colours + parallel generation

Fix some wallpapers not having enough colours by disabling filter (also gives better colours)
Use GNU parallel to run scheme generation in parallel
Also ensure all schemes exist when generating
Cache wallpaper thumbnails
This commit is contained in:
2 * r + 2 * t
2025-04-07 11:38:05 +10:00
parent bf6ddf7963
commit f9a83990a9
4 changed files with 17 additions and 13 deletions
+1 -1
View File
@@ -2,7 +2,7 @@
. (dirname (status filename))/util.fish . (dirname (status filename))/util.fish
install-deps git hyprland-git hyprpaper-git imagemagick wl-clipboard fuzzel-git socat foot jq python xdg-user-dirs python-materialyoucolor-git app2unit-git install-deps git hyprland-git hyprpaper-git imagemagick wl-clipboard fuzzel-git socat foot jq python xdg-user-dirs python-materialyoucolor-git app2unit-git parallel
install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'zen-browser (web browser)' 'spotify-adblock (music player)' install-optional-deps 'equibop-bin (discord client)' 'btop (system monitor)' 'wf-recorder (screen recorder)' 'grim (screenshot tool)' 'zen-browser (web browser)' 'spotify-adblock (music player)'
set -l dist $C_DATA/scripts set -l dist $C_DATA/scripts
+11 -5
View File
@@ -12,13 +12,19 @@ set -l hash (sha1sum $img | cut -d ' ' -f 1)
# Cache schemes # Cache schemes
mkdir -p $C_CACHE/schemes mkdir -p $C_CACHE/schemes
if ! test -d $C_CACHE/schemes/$hash set -l dirty_variants
# Generate colours if test -d $C_CACHE/schemes/$hash
set -l colours ($src/score.py $img)
for variant in $variants for variant in $variants
mkdir -p $C_CACHE/schemes/$hash/$variant test -f $C_CACHE/schemes/$hash/$variant/$theme.txt || set -a dirty_variants $variant
$src/autoadjust.py $theme $variant $colours | head -c -1 > $C_CACHE/schemes/$hash/$variant/$theme.txt
end end
else
set dirty_variants $variants
end
if test -n "$dirty_variants"
# Generate schemes for variants that need it
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
end end
# Copy schemes from cache # Copy schemes from cache
+1 -1
View File
@@ -22,7 +22,7 @@ class Score:
@staticmethod @staticmethod
def score(colors_to_population: dict) -> list[int]: def score(colors_to_population: dict) -> list[int]:
desired = 14 desired = 14
filter_enabled = True filter_enabled = False
dislike_filter = True dislike_filter = True
colors_hct = [] colors_hct = []
+4 -6
View File
@@ -107,13 +107,11 @@ else
hyprctl hyprpaper unload unused > /dev/null hyprctl hyprpaper unload unused > /dev/null
# Thumbnail wallpaper for colour gen # Thumbnail wallpaper for colour gen
set -l thumb_path $C_CACHE/thumbnails/(string replace -a '/' '-' (dirname $chosen_wallpaper | string sub -s 2))-(path change-extension '.jpg' (basename $chosen_wallpaper)) set -l thumb_path $C_CACHE/thumbnails/(sha1sum $chosen_wallpaper | cut -d ' ' -f 1).jpg
if test -f $thumb_path if ! test -f $thumb_path
# Use thumbnail from shell magick -define jpeg:size=256x256 $chosen_wallpaper -thumbnail 128x128 $thumb_path
cp $thumb_path $state_dir/thumbnail.jpg
else
magick -define jpeg:size=256x256 $chosen_wallpaper -thumbnail 128x128 $state_dir/thumbnail.jpg
end end
cp $thumb_path $state_dir/thumbnail.jpg
# Generate colour scheme for wallpaper # Generate colour scheme for wallpaper
set -l src (dirname (status filename)) set -l src (dirname (status filename))