Add experimental WIP sorting functionality to menu

This commit is contained in:
JeremyStar™ 2024-06-15 15:51:25 +02:00
parent 9926ec4048
commit add62d1929
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D

View file

@ -25,9 +25,38 @@ for script in "${HOME}"/.config/launch-menu-apps.d/*.sh; do
source "${script}" source "${script}"
done done
# Sort entries
if [ -n "${MENU_SORT}" ]; then
echo ":: Warning: Sorting is currently broken and is considered experimental"
declare -a apps_sorted=($(
for app in "${!apps[@]}"; do
echo "[\"${key}\"]=${apps[${app}]}"
done | sort
))
unset apps
declare -A apps=()
for app in "${!apps_sorted[@]}"; do
key=$(echo -n "${apps_sorted[${app}]}" | grep -o '\["[A-Za-z]+"\]' || true)
value=$(echo -n "${apps_sorted[${app}]}" | grep -o '"[A-Za-z]+"' || true)
echo ":: COPY BSE: ${apps_sorted[@]}"
echo ":: KEY: ${key}"
echo " VAL: ${value}"
apps+=(
["${app}"]="${apps_sorted[${app}]}"
)
done
fi
# Create new variables # Create new variables
apps_keys= apps_keys=
for app in "${!apps[@]}"; do for app in "${!apps[@]}"; do
if [ -n "${MENU_SORT}" ]; then
echo ":: KEYC KEY: ${app}"
echo " VAL: ${apps[${app}]}"
fi
[[ -n "${apps_keys}" ]] && apps_keys="${apps_keys}\n" [[ -n "${apps_keys}" ]] && apps_keys="${apps_keys}\n"
apps_keys=${apps_keys}${app} apps_keys=${apps_keys}${app}
done done