So today, I decided to download an appimage. Appimages are nice, as they pack all dependencies into one file, so there is no dependency hell. This is somewhat similar to what Apple and Haiku are doing, but for Linux. But this is not really about appimages, the same problem goes for regular executable as well.
To properly install the appimage, I had to:
make it executable
move it to appropriate directory (e.g. ~/.local/bin/)
add a desktop file for it (some supposedly do that themselves, but not all)
That is a lot of things to do. And so I wrote a little script. Well, two in fact, as I sometimes want to make a desktop file for executable outside of '~/.local/bin/' as well.
First, the base script. Let's call it 'inst.sh':
#!/bin/sh
help() {
echo "usage: inst.sh [flags] "
echo "flags:"
echo " -d, --desktop add a desktop entry"
}
desktop=false
desktop_name=""
path=""
while [ "$#" -gt 0 ]; do
case $1 in
-d|--desktop)
desktop=true
desktop_name="$2"
shift
shift
;;
*)
path=$1
shift
;;
esac
done
if [ path = "" ]; then
help
exit 1
fi
filename="$(basename $path)"
dest="$HOME/.local/bin/$filename"
chmod +x $path
mv $path $dest
if [ $desktop = true ]; then
make-desktop.sh $dest "$desktop_name"
fi
It might look intimidating, but that's just because shell takes a lot of space. Most of the script is argument handling. Some might say that I should have used
but there seem to be some significant differences between the GNU and BSD versions and I like to keep my scripts multiplatform. (Plus it's not really needed here)
Shift moves all the args one position lower, discarding the first. You can use