Add launch-menu-apps script

This commit is contained in:
JeremyStar™ 2024-06-03 22:41:10 +02:00
parent c7f560b35e
commit ee23195164
Signed by: JeremyStarTM
GPG key ID: E366BAEF67E4704D
3 changed files with 43 additions and 0 deletions

41
bash/bin/launch-menu-apps Executable file
View file

@ -0,0 +1,41 @@
#!/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
selection=$(echo -e "${apps_keys}" | launch-menu)
# Execute
# shellcheck disable=SC2086
( eval ${apps[${selection}]} )

View file

@ -46,6 +46,7 @@ link "repositories/dracula-mc/skins/dracula256.ini" ".local/share/mc/skins/dracu
link "bash/bashrc" ".bashrc"
link "repositories/punktdateien-bashrc" ".bashrc.d"
link "bash/bin/launch-menu" ".local/bin/launch-menu"
link "bash/bin/launch-menu-apps" ".local/bin/launch-menu-apps"
link "bash/jobrunner/daemon.sh" ".local/bin/jobrunner"
link "bash/jobrunner/runjob.sh" ".local/bin/jobrunner-runjob"
link "bash/starship.toml" ".config/starship.toml"

View file

@ -103,6 +103,7 @@ unlink ".local/share/mc/skins/dracula256.ini"
# bash
unlink ".bashrc"
unlink ".local/bin/launch-menu"
unlink ".local/bin/launch-menu-apps"
unlink ".local/bin/jobrunner"
unlink ".local/bin/jobrunner-runjob"
unlink ".config/jstmbash.env"