Add experimental WIP sorting functionality to menu
This commit is contained in:
parent
9926ec4048
commit
add62d1929
1 changed files with 29 additions and 0 deletions
|
@ -25,9 +25,38 @@ for script in "${HOME}"/.config/launch-menu-apps.d/*.sh; do
|
|||
source "${script}"
|
||||
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
|
||||
apps_keys=
|
||||
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"
|
||||
apps_keys=${apps_keys}${app}
|
||||
done
|
||||
|
|
Loading…
Reference in a new issue