Skip to content

Instantly share code, notes, and snippets.

@JohnTheCoolingFan
Created September 4, 2024 16:36
Show Gist options
  • Save JohnTheCoolingFan/c23567fd4c55e2f67988569a8fb0a552 to your computer and use it in GitHub Desktop.
Save JohnTheCoolingFan/c23567fd4c55e2f67988569a8fb0a552 to your computer and use it in GitHub Desktop.
A script to install an appimage and add its desktop file to the applications menu. Only uses user directories in `~/.local/`. Why do 2 out of 3 appimage management tools are written in go with no vendor dir in repo and the third one requires qt? Either way, this is a simple way to "install" an appimage. If a removal script is wanted I'll make on…
#!/bin/bash
APPIMAGE_FILE=$(realpath $1)
[[ $APPIMAGE_FILE == *.AppImage ]] || (echo "File doesn't have AppImage extension" && exit 1)
TEMPDIR=$(mktemp -d)
function unpack_and_install() {
$APPIMAGE_FILE --appimage-extract 'usr/share/icons/*' > /dev/null
cp -r squashfs-root/usr/share/icons/* ~/.local/share/icons/
$APPIMAGE_FILE --appimage-extract '*.desktop' > /dev/null
APPIMAGE_DESKTOP_FILE=$(find squashfs-root -type f -iname '*.desktop')
sed -e "s/Exec=AppRun --no-sandbox %U/Exec=\/home\/${USER}\/.local\/bin\/$(basename $APPIMAGE_FILE)/" -i $APPIMAGE_DESKTOP_FILE
cp $APPIMAGE_DESKTOP_FILE ~/.local/share/applications
cp $APPIMAGE_FILE ~/.local/bin/
}
(cd $TEMPDIR; unpack_and_install; cd /; rm -r $TEMPDIR)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment