Call alternative binary from appimage?

Check out the new $ARGV0 environment variable that gets exported by the AppImage runtime since https://github.com/AppImage/AppImageKit/commit/63485edeb854e8e830f201280a61bb803a4ddaa3

Example of how this can be used:

me@host:~$ ln -s Downloads/ippsample-git.4fbfa3f-x86_64.AppImage ipptool

me@host:~$ ./ipptool 
Usage: ipptool [options] URI filename [ ... filenameN ]
(...)

me@host:~$ ln -s Downloads/ippsample-git.4fbfa3f-x86_64.AppImage ippserver

me@host:~$ ./ippserver 
Usage: ippserver [options] "name"
(...)

This is achieved by using this custom AppRun script: https://github.com/probonopd/ippsample/blob/patch-1/appimage/AppRun

#!/bin/bash

# The purpose of this custom AppRun script is
# to allow symlinking the AppImage and invoking
# the corresponding binary depending on which
# symlink was used to invoke the AppImage

HERE="$(dirname "$(readlink -f "${0}")")"

if [ ! -z $APPIMAGE ] ; then
  BINARY_NAME=$(basename "$ARGV0")
  if [ -e "$HERE/usr/bin/$BINARY_NAME" ] ; then
    exec "$HERE/usr/bin/$BINARY_NAME" "$@"
  else
    exec "$HERE/usr/bin/ippserver" "$@"
  fi
else
  exec "$HERE/usr/bin/ippserver" "$@"
fi
1 Like