Skip to content

Instantly share code, notes, and snippets.

@PJ-Oscheh
Last active July 10, 2021 18:53
Show Gist options
  • Save PJ-Oscheh/7d92fa54dd64700594ddca6854ec642f to your computer and use it in GitHub Desktop.
Save PJ-Oscheh/7d92fa54dd64700594ddca6854ec642f to your computer and use it in GitHub Desktop.
App Image Installer: Easily install AppImages to your system if that functionality doesn't exist by default. While it doesn't work for all, for most AppImages, it will extract the icon and create a .desktop file. Still needs some touch-ups. (I designed this for Ubuntu with GNOME; it may work for other Distros/DEs or it may not lol)
#!/bin/bash
#AppImage Installer
#For yes: run `appimage-extract` to get the icon, create .desktop.
#Installs the AppImage
installImage () {
if [[ -d ./working ]]; then
printf "Working directory exists, deleting...\n"
rm -R ./working
else
printf "Working directory does not exist.\n"
fi
printf "Creating working directory\n"
mkdir "./working"
cd "./working"
printf "Extracting for icon...\n"
$file --appimage-extract >&-
if [[ -d ./squashfs-root ]]; then #Get the icon
printf "AppImage extracted successfully.\n"
cd ./squashfs-root
#Icons do not have consistent names. For now, let's just play a wild card and hope for the best :)
cp *.svg ../icon.svg
cp *.png ../icon.png
cd ../
else
printf "The AppImage couldn't be extracted, so no icon can be used. You can add one manually later.\n"
fi
if [[ -f ./icon.svg ]]; then
icon=`readlink -f ./icon.svg`
elif [[ -f ./icon.png ]]; then
icon=`readlink -f ./icon.png`
fi
printf "[Desktop Entry]\nType=Application\nName=$name\nIcon=$icon\nExec=$file\nTerminal=false" > newDesktop.desktop #Create the launcher
cp ./newDesktop.desktop ~/.local/share/applications/$name.desktop
printf "Done! Launcher saved to ~/.local/share/applications/$name.desktop\n"
}
name="$2"
file="$1"
#Currently, spaces can't be used.
printf "You will install $file, with the name \""$name"\"\n"
read -p "Proceed? (y/n)" choice
if [ $choice == "y" ]
then
printf "Beginning installation of $file.\n"
installImage
elif [ $choice == "n" ]
then
printf "Aborted.\n"
else
printf "Invalid. Aborted.\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment