Skip to content

Commit 2ff0bd5

Browse files
committed
AppRun: allow running with symlinks
resolve tool from $APPIMAGE ($0; progname) This allows running the reflector with just `hd-rum-transcode` if symlinked with that name.
1 parent 994c8ea commit 2ff0bd5

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

  • data/scripts/Linux-AppImage

data/scripts/Linux-AppImage/AppRun

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ bold=$(tput bold || true)
1212
red=$(tput setaf 1 || true)
1313
reset=$(tput sgr0 || true)
1414

15-
DIR=$(dirname "$0")
15+
DIR=$(dirname "$(realpath "$0")")
1616
readonly AI_LIB_PATH="$DIR"/usr/lib
1717
n_ld_library_path="$AI_LIB_PATH"${LD_LIBRARY_PATH:+":$LD_LIBRARY_PATH"}
1818
LD_PRELOAD=${LD_PRELOAD-}
@@ -33,6 +33,21 @@ get_tools() {(
3333
find "$DIR/usr/bin" -mindepth 1 -exec basename {} \; | tr '\n' ' '
3434
)}
3535

36+
# handle symlinks, so eg. if symlinked to hd-rum-transcode, ruh the transcoder
37+
# (no need to use `U.traGrid...AppImage -o hd-rum-transcode`)
38+
get_tool_from_progname() {(
39+
prog=$(basename "${ARGV0?}")
40+
# shellcheck disable=SC2046 # intentional
41+
set -- $(get_tools)
42+
while [ $# -gt 0 ]; do
43+
if [ "$prog" = "$1" ]; then
44+
echo "$1"
45+
return
46+
fi
47+
shift
48+
done
49+
)}
50+
3651
usage() {
3752
printf "usage:\n"
3853
printf "\t${bold}${red}%s${reset} ${bold}[--gui [args]]${reset}\n" "$ARGV0"
@@ -393,6 +408,11 @@ if [ "${APPIMAGE_DEBUG-undef}" = undef ] && [ "${ULTRAGRID_VERBOSE-}" ]; then
393408
APPIMAGE_DEBUG=$ULTRAGRID_VERBOSE
394409
fi
395410

411+
tool=$(get_tool_from_progname)
412+
if [ "$tool" ]; then
413+
set -- -o "$tool" "$@"
414+
fi
415+
396416
if [ $# -eq 0 ] || [ "${1-}" = "--gui" ]; then
397417
handle_autoupdates "$@"
398418
if [ $# -eq 0 ]; then usage; else shift; fi

0 commit comments

Comments
 (0)