Preview theme colors in the theme picker

This commit is contained in:
SirBlob committed 2026-09-24 01:35:26 +00:00
1 parent cfafe8825b
commit 3cc1299e5b
4 files changed
+56 -9

No files matched your search

+21 -2
View File
@@ -20,8 +20,27 @@ current_mode() {
fi
}
theme_swatches() {
awk -F'"' '
/^[a-z_]+ *= *"#[0-9A-Fa-f]+"/ {
split($1, key_parts, /[ =]/)
colors[key_parts[1]] = $2
}
END {
count = split("background foreground accent red green yellow blue magenta cyan", swatch_keys, " ")
for (index_number = 1; index_number <= count; index_number++) {
color = colors[swatch_keys[index_number]]
if (color != "") printf "%s%s", (printed++ ? " " : ""), color
}
}
' "$1"
}
list_theme_rows() {
printf '\tDynamic (from wallpaper)\tblob-dynamic\n'
local dynamic_colors="$current_dir/theme/colors.toml"
local dynamic_swatches=""
[ "$(current_mode)" = "dynamic" ] && [ -f "$dynamic_colors" ] && dynamic_swatches=$(theme_swatches "$dynamic_colors")
printf '\tDynamic (from wallpaper)\tblob-dynamic\t%s\n' "$dynamic_swatches"
{
find "$user_themes_dir" -mindepth 1 -maxdepth 1 -type d 2>/dev/null
@@ -30,7 +49,7 @@ list_theme_rows() {
[ -f "$theme_dir/colors.toml" ] || continue
slug=$(basename "$theme_dir")
[ "$slug" = "blob-dynamic" ] && continue
printf '\t%s\t%s\n' "$(prettify "$slug")" "$slug"
printf '\t%s\t%s\t%s\n' "$(prettify "$slug")" "$slug" "$(theme_swatches "$theme_dir/colors.toml")"
done | sort -u -t$'\t' -k3,3
}