41 lines
1.3 KiB
Bash
Executable File
41 lines
1.3 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# Install Panama's searchable launcher actions as one narrow directory link.
|
|
# Keeping the runtime path stable lets Vicinae watch it while every command
|
|
# remains authored and reviewed in the Panama repository.
|
|
|
|
set -euo pipefail
|
|
|
|
panama_path="${PANAMA_PATH:-$HOME/.local/share/Panama}"
|
|
vicinae_data_dir="${VICINAE_DATA_DIR:-$HOME/.local/share/vicinae}"
|
|
source_dir="$panama_path/config/local/share/vicinae/scripts"
|
|
scripts_dir="$vicinae_data_dir/scripts"
|
|
target_dir="$scripts_dir/panama"
|
|
backup_dir="$scripts_dir/panama.pre-panama"
|
|
|
|
[[ -d "$source_dir" ]] || {
|
|
printf 'Panama command source is missing: %s\n' "$source_dir" >&2
|
|
exit 1
|
|
}
|
|
|
|
mkdir -p "$scripts_dir"
|
|
|
|
if [[ -L "$target_dir" ]]; then
|
|
rm "$target_dir"
|
|
elif [[ -e "$target_dir" ]]; then
|
|
if [[ -e "$backup_dir" ]]; then
|
|
printf 'Refusing to replace %s; backup already exists at %s\n' \
|
|
"$target_dir" "$backup_dir" >&2
|
|
exit 1
|
|
fi
|
|
mv "$target_dir" "$backup_dir"
|
|
fi
|
|
|
|
ln -s "$source_dir" "$target_dir"
|
|
|
|
# The server also rescans periodically, but an explicit reload makes a setup
|
|
# run deterministic. If Vicinae is not active yet, its startup scan is enough.
|
|
if command -v vicinae >/dev/null 2>&1 && vicinae ping >/dev/null 2>&1; then
|
|
vicinae cmd launch core:reload-scripts >/dev/null 2>&1 || true
|
|
fi
|