2024-06-03 22:41:10 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Define associative array
|
|
|
|
declare -A apps=()
|
|
|
|
|
|
|
|
[[ ! -d "${HOME:?}/.config/launch-menu-apps.d" ]] && (
|
|
|
|
mkdir -p "${HOME}/.config/launch-menu-apps.d"
|
|
|
|
cat << EOF >> "${HOME}/.config/launch-menu-apps.d/template.sh.disabled"
|
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
apps+=(
|
|
|
|
["Example application"]="example-application"
|
|
|
|
["Test script"]="${HOME}/.local/bin/test-script"
|
|
|
|
)
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
# shellcheck disable=SC2012
|
|
|
|
[[ "$(ls -1 "${HOME}"/.config/launch-menu-apps.d/*.sh 2>/dev/null | wc -l)" == "0" ]] && exit 0
|
|
|
|
|
|
|
|
# Append entries
|
|
|
|
for script in "${HOME}"/.config/launch-menu-apps.d/*.sh; do
|
|
|
|
echo ":: Sourcing script ${script}"
|
|
|
|
# shellcheck disable=SC1090
|
|
|
|
source "${script}"
|
|
|
|
done
|
|
|
|
|
|
|
|
# Create new variables
|
|
|
|
apps_keys=
|
|
|
|
for app in "${!apps[@]}"; do
|
|
|
|
[[ -n "${apps_keys}" ]] && apps_keys="${apps_keys}\n"
|
|
|
|
apps_keys=${apps_keys}${app}
|
|
|
|
done
|
|
|
|
|
|
|
|
# Make selection
|
2024-06-04 00:40:24 +02:00
|
|
|
selection=$(echo -e "${apps_keys}" | ${HOME}/.local/bin/launch-menu "start")
|
2024-06-03 22:41:10 +02:00
|
|
|
|
|
|
|
# Execute
|
|
|
|
# shellcheck disable=SC2086
|
|
|
|
( eval ${apps[${selection}]} )
|