Created
November 14, 2023 10:05
-
-
Save naranyala/d8eee2fe3478c46d130e0c14d7843d9b to your computer and use it in GitHub Desktop.
create a shell alias like "alias install-appimage='$HOME/bin/the-script.sh'" to execute wherever the current directory path is
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Check if the AppImage file path is provided | |
if [ -z "$1" ]; then | |
echo "Error: Please provide the path to the AppImage file as the first argument." | |
exit 1 | |
fi | |
# Path to the AppImage file | |
appimage_path="$1" | |
# Prompt the user for the custom app name | |
read -p "Enter a custom app name: " app_name | |
# Check if the provided name is not empty | |
if [ -z "$app_name" ]; then | |
echo "Error: Custom app name cannot be empty." | |
exit 1 | |
fi | |
# Directory to move the AppImage to | |
install_dir="/opt/$app_name" | |
# Path to the .desktop file | |
desktop_file="/usr/share/applications/$app_name.desktop" | |
# Check if the AppImage file exists | |
if [ ! -f "$appimage_path" ]; then | |
echo "Error: AppImage file not found." | |
exit 1 | |
fi | |
# Create the installation directory | |
sudo mkdir -p "$install_dir" | |
# Move the AppImage to the installation directory | |
sudo cp "$appimage_path" "$install_dir" | |
# Create a .desktop file | |
echo "[Desktop Entry] | |
Name=$app_name | |
Exec=\"$install_dir/$(basename "$appimage_path")\" | |
Icon=$install_dir/your_icon.png | |
Type=Application | |
Categories=Utility;" | sudo tee "$desktop_file" >/dev/null | |
# Make the .desktop file executable | |
sudo chmod +x "$desktop_file" | |
# Inform the user | |
echo "Installation complete. You can now launch \"$app_name\" from the application menu." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment