Created
November 7, 2024 04:51
-
-
Save naranyala/b4b1990a3336ae5e23d5973509ee07c0 to your computer and use it in GitHub Desktop.
This file contains 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" | |
# Set execute permissions on the AppImage | |
sudo chmod +x "$install_dir/$(basename "$appimage_path")" | |
# Set execute permissions on the install directory | |
sudo chmod +x "$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