Preview theme colors in the theme picker
This commit is contained in:
1 parent
cfafe8825b
commit
3cc1299e5b
4 files changed
+56
-9
No files matched your search
@@ -7,8 +7,9 @@
|
||||
# blob:examples=blob menu select Format jpg png|blob-menu-select Resolution 4k 1080p 720p -- --width 400
|
||||
|
||||
# An option may lead with an icon, as "<glyph><TAB><label>", and may trail a
|
||||
# subtext shown under the label, as "<glyph><TAB><label><TAB><subtext>". The
|
||||
# menu shows the glyph but never returns it. A plain option returns the label
|
||||
# subtext shown under the label, as "<glyph><TAB><label><TAB><subtext>", and
|
||||
# then space-separated hex colors drawn as swatches, as a fourth field. The
|
||||
# menu shows the glyph and swatches but never returns them. A plain option returns the label
|
||||
# alone; an option with a subtext returns "<label><TAB><subtext>", so callers
|
||||
# with same-named rows get the subtext back as the stable key.
|
||||
|
||||
|
||||
+21
-2
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user