Performance improve pickers
This commit is contained in:
@@ -8,6 +8,7 @@ OMARCHY_THEMES_PATH="$OMARCHY_PATH/themes"
|
||||
CACHE_PATH="${XDG_CACHE_HOME:-$HOME/.cache}/omarchy/theme-selector"
|
||||
preview_dir="$CACHE_PATH/previews"
|
||||
signature_file="$CACHE_PATH/signature"
|
||||
fast_signature_file="$CACHE_PATH/fast-signature"
|
||||
|
||||
mkdir -p "$preview_dir"
|
||||
|
||||
@@ -41,23 +42,36 @@ add_theme_preview() {
|
||||
ln -s "$preview" "$preview_dir/$theme_name.$extension"
|
||||
}
|
||||
|
||||
theme_signature=""
|
||||
fast_signature="v1"$'\n'
|
||||
for theme_dir in "$USER_THEMES_PATH" "$OMARCHY_THEMES_PATH"; do
|
||||
if [[ -d $theme_dir ]]; then
|
||||
theme_signature+="$theme_dir:$(stat -Lc '%Y' "$theme_dir")"$'\n'
|
||||
fast_signature+="$theme_dir:$(stat -Lc '%Y' "$theme_dir")"$'\n'
|
||||
|
||||
while IFS= read -r -d '' theme_path; do
|
||||
preview=$(find_preview "$theme_path")
|
||||
theme_signature+="$theme_path:$(stat -Lc '%Y' "$theme_path")"$'\n'
|
||||
|
||||
if [[ -n $preview ]]; then
|
||||
theme_signature+="$preview:$(stat -Lc '%s:%Y' "$preview")"$'\n'
|
||||
fi
|
||||
fast_signature+="$theme_path:$(stat -Lc '%Y' "$theme_path")"$'\n'
|
||||
done < <(find -L "$theme_dir" -mindepth 1 -maxdepth 1 \( -type d -o -type l \) -print0 2>/dev/null | sort -z)
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -f $signature_file ]] || ! cmp -s "$signature_file" <(printf '%s' "$theme_signature"); then
|
||||
if [[ ! -f $fast_signature_file ]] || ! cmp -s "$fast_signature_file" <(printf '%s' "$fast_signature"); then
|
||||
theme_signature=""
|
||||
for theme_dir in "$USER_THEMES_PATH" "$OMARCHY_THEMES_PATH"; do
|
||||
if [[ -d $theme_dir ]]; then
|
||||
theme_signature+="$theme_dir:$(stat -Lc '%Y' "$theme_dir")"$'\n'
|
||||
|
||||
while IFS= read -r -d '' theme_path; do
|
||||
preview=$(find_preview "$theme_path")
|
||||
theme_signature+="$theme_path:$(stat -Lc '%Y' "$theme_path")"$'\n'
|
||||
|
||||
if [[ -n $preview ]]; then
|
||||
theme_signature+="$preview:$(stat -Lc '%s:%Y' "$preview")"$'\n'
|
||||
fi
|
||||
done < <(find -L "$theme_dir" -mindepth 1 -maxdepth 1 \( -type d -o -type l \) -print0 2>/dev/null | sort -z)
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ ! -f $fast_signature_file ]] || ! cmp -s "$fast_signature_file" <(printf '%s' "$fast_signature"); then
|
||||
rm -rf "$preview_dir"
|
||||
mkdir -p "$preview_dir"
|
||||
|
||||
@@ -79,6 +93,7 @@ if [[ ! -f $signature_file ]] || ! cmp -s "$signature_file" <(printf '%s' "$them
|
||||
done < <(find -L "$OMARCHY_THEMES_PATH" -mindepth 1 -maxdepth 1 -type d -print 2>/dev/null | sort)
|
||||
|
||||
printf '%s' "$theme_signature" >"$signature_file"
|
||||
printf '%s' "$fast_signature" >"$fast_signature_file"
|
||||
fi
|
||||
|
||||
current_theme=$(cat "$HOME/.config/omarchy/current/theme.name" 2>/dev/null)
|
||||
|
||||
Reference in New Issue
Block a user