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:
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] <bin>" echo "flags:" echo " -d, --desktop <name> 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 getopt(1), 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 basename(1) to get file name from path and dirname(1) to get the path.
The second script, 'make-desktop.sh', is the following:
#!/bin/sh if [ "$#" -ne 2 ]; then echo "usage: make-desktop.sh <source> <name>" exit 1 fi src="$1" name="$2" dest="$HOME/.local/share/applications/$name.desktop" echo "[Desktop Entry] Type=Application Name=$name Exec=$src Terminal=false " > $dest
Desktop files are used for app launchers, such as rofi or fuzzel, to find out what applications to show and under what names.
Now just calculate how much appimages do I need to install in order to save more time than I spend writing it...