From cb4fd8ba73acbfb438e1f56637bf9cf63f6d61d2 Mon Sep 17 00:00:00 2001 From: Travis Lane <63308171+Tormak9970@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:40:48 -0500 Subject: [PATCH 1/2] chore: add linux targets --- build-resources/appimage-installer.sh | 152 ++++++++++++++++++++++++ build-resources/appimage-uninstaller.sh | 83 +++++++++++++ src-tauri/tauri.conf.json | 4 +- 3 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 build-resources/appimage-installer.sh create mode 100644 build-resources/appimage-uninstaller.sh diff --git a/build-resources/appimage-installer.sh b/build-resources/appimage-installer.sh new file mode 100644 index 00000000..cdba6b39 --- /dev/null +++ b/build-resources/appimage-installer.sh @@ -0,0 +1,152 @@ +#!/bin/bash +# Author: Travis Lane + +errorRed='\033[1;91m' +warningYellow='\033[1;93m' +tipBlue='\033[1;94m' +successGreen='\033[1;96m' +infoCyan='\033[1;92m' +noColor='\033[0m' + +comment="An offline first music player for your music library." +uninstallComment="Uninstalls all files related to Svunes." + +currentVersion="v2.9.0" + +# Show starting message. +echo -e "${infoCyan}[INFO]${noColor}: Installing Svunes $currentVersion..." +echo "" +echo -e "${tipBlue}[TIP]${noColor}: If Svunes doesn't install, try closing this window and running it again. Sometimes it takes 3-5 attempts to install, looking into the cause." + +# Check for a Github.com connection +echo -e "${infoCyan}[INFO]${noColor}: Checking connection to GitHub.com..." +case "$(curl -s --max-time 2 -I http://github.com | sed 's/^[^ ]* *\([0-9]\).*/\1/; 1q')" in + [23]) + echo -e "${successGreen}[INFO]${noColor}: Able to reach Github.com" + ;; + 5) + echo -e "${errorRed}[ERROR]${noColor}: The web proxy won't let requests through." + read -p "Press any key to quit the installer" + exit 1 + ;; + *) + echo -e "${errorRed}[ERROR]${noColor}: The network is down or very slow." + read -p "Press any key to quit the installer" + exit 1 + ;; +esac + +# Check if the .svunes directory already exists. +if [ -d "$HOME/.svunes" ]; then + echo -e "${successGreen}[INFO]${noColor}: Svunes Directory Exists." +else + mkdir $HOME/.svunes + echo -e "${successGreen}[INFO]${noColor}: Made Svunes Directory." +fi +echo "" + +# Download the latest appimage from GitHub. +rm -rf "$HOME"/.svunes/svunes.AppImage 2>/dev/null +echo -e "${infoCyan}[INFO]${noColor}: Downloading AppImage..." +curl -L https://github.com/Tormak9970/Svunes/releases/download/$currentVersion/svunes.AppImage --output ~/.svunes/svunes.AppImage +chmod 700 ~/.svunes/svunes.AppImage +echo -e "${successGreen}[INFO]${noColor}: Downloaded AppImage." +echo "" + +# Download the uninstall script from GitHub. +rm -rf "$HOME"/.svunes/appimage-uninstaller.sh 2>/dev/null +echo -e "${infoCyan}[INFO]${noColor}: Downloading Uninstall Script..." +curl -L https://raw.githubusercontent.com/Tormak9970/Svunes/$currentVersion/build-resources/appimage-uninstaller.sh --output ~/.svunes/appimage-uninstaller.sh +chmod 700 ~/.svunes/linux-uninstaller.sh +echo -e "${successGreen}[INFO]${noColor}: Downloaded Uninstall Script." +echo "" + +# Download the icon from GitHub. +rm -rf "$HOME"/.svunes/svunes.png 2>/dev/null +echo -e "${infoCyan}[INFO]${noColor}: Downloading Icon..." +curl https://raw.githubusercontent.com/Tormak9970/Svunes/$currentVersion/public/logo.png --output ~/.svunes/svunes.png +echo -e "${successGreen}[INFO]${noColor}: Downloaded Icon." +echo "" + + +absSvunesPath="$HOME/.svunes" +appImagePath="$absSvunesPath/svunes.AppImage" +iconPath="$absSvunesPath/svunes.png" + +cd $absSvunesPath +xdg-icon-resource install svunes.png --size 64 +xdg-icon-resource install svunes.png --size 128 +xdg-icon-resource install svunes.png --size 256 +echo -e "${successGreen}[INFO]${noColor}: Updated Icon Database." +echo "" + + +echo -e "${infoCyan}[INFO]${noColor}: Making Shortcuts..." + +# Create the launcher .desktop. +read -r -d '' openSvunesContents <<- EOM +#!/usr/bin/env xdg-open +[Desktop Entry] +Comment=$comment +Name=Svunes +Exec=GTK_USE_PORTAL=1 WEBKIT_DISABLE_COMPOSITING_MODE=1 $appImagePath +Icon=$iconPath +Terminal=false +Type=Application +Categories=Utility +StartupNotify=false + +EOM + +uninstallScriptPath="$absSvunesPath/appimage-uninstaller.sh" + +# Create the uninstaller .desktop. +read -r -d '' uninstallSvunesContent <<- EOM +#!/usr/bin/env xdg-open +[Desktop Entry] +Comment=$uninstallComment +Name=Uninstall Svunes +Exec=$uninstallScriptPath +Icon=delete +Terminal=true +Type=Application +Categories=Utility +StartupNotify=false + +EOM + +# Create the start menu launcher. +rm -rf "$HOME"/.local/share/applications/svunes.desktop 2>/dev/null +echo -e "$openSvunesContents" >> $HOME/.local/share/applications/svunes.desktop +chmod 700 $HOME/.local/share/applications/svunes.desktop +echo -e "${successGreen}[INFO]${noColor}: Made Start Menu Shortcut." + +# Create the desktop launcher. +rm -rf "$HOME"/Desktop/svunes.desktop 2>/dev/null +echo -e "$openSvunesContents" >> $HOME/Desktop/svunes.desktop +chmod 700 $HOME/Desktop/svunes.desktop +echo -e "${successGreen}[INFO]${noColor}: Made Desktop Shortcut." + +# Create the start menu uninstaller. +rm -rf "$HOME"/.local/share/applications/uninstall-svunes.desktop 2>/dev/null +echo -e "$uninstallSvunesContent" >> $HOME/.local/share/applications/uninstall-svunes.desktop +chmod 700 $HOME/.local/share/applications/uninstall-svunes.desktop +echo -e "${successGreen}[INFO]${noColor}: Made Start Menu Uninstall Shortcut." + +# Create the desktop uninstaller. +rm -rf "$HOME"/Desktop/uninstall-svunes.desktop 2>/dev/null +echo -e "$uninstallSvunesContent" >> $HOME/Desktop/uninstall-svunes.desktop +chmod 700 $HOME/Desktop/uninstall-svunes.desktop +echo -e "${successGreen}[INFO]${noColor}: Made Desktop Uninstall Shortcut." + +echo -e "${successGreen}[INFO]${noColor}: Finished Making Shortcuts." +echo "" + +# Update .desktop database. +update-desktop-database $HOME/.local/share/applications +echo -e "${successGreen}[INFO]${noColor}: Updated .desktop database." +echo "" + +echo -e "${successGreen}[INFO]${noColor}: Instalation of Svunes $currentVersion complete." +echo "" +echo -e "${tipBlue}[TIP]${noColor}: Feel free to delete this script. Svunes will notify you when new updates are available!" \ No newline at end of file diff --git a/build-resources/appimage-uninstaller.sh b/build-resources/appimage-uninstaller.sh new file mode 100644 index 00000000..6a07df75 --- /dev/null +++ b/build-resources/appimage-uninstaller.sh @@ -0,0 +1,83 @@ +#!/bin/bash +# Author: Travis Lane + +errorRed='\033[1;91m' +warningYellow='\033[1;93m' +tipBlue='\033[1;94m' +successGreen='\033[1;96m' +infoCyan='\033[1;92m' +noColor='\033[0m' + +if zenity --question --title="Warning!" --text="You are about to uninstall Svunes and all of its files.\n\n Are you sure you want to proceed?" --width=600; then + echo -e "${infoCyan}[INFO]${noColor}: Uninstalling Svunes..." + echo "" + + # Delete install directory + if [ -d "$HOME/.svunes" ]; then + rm -rf "$HOME/.svunes" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes directory." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes directory already removed." + fi + + # Remove Desktop icons + if [ -d "$HOME/Desktop/svunes.desktop" ]; then + rm -rf "$HOME/Desktop/svunes.desktop" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes desktop launch shortcut." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes desktop launch shortcut already removed." + fi + + if [ -d "$HOME/Desktop/uninstall-svunes.desktop" ]; then + rm -rf "$HOME/Desktop/uninstall-svunes.desktop" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes desktop uninstall shortcut." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes desktop uninstall shortcut already removed." + fi + + # Remove Start Menu shortcuts + if [ -d "$HOME/.local/share/applications/svunes.desktop" ]; then + rm -rf "$HOME/.local/share/applications/svunes.desktop" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes start menu launch shortcut." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes start menu launch shortcut already removed." + fi + + if [ -d "$HOME/.local/share/applications/uninstall-svunes.desktop" ]; then + rm -rf "$HOME/.local/share/applications/uninstall-svunes.desktop" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes start menu uninstall shortcut." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes start menu uninstall shortcut already removed." + fi + + # Remove cache directory + if [ -d "$HOME/.cache/dev.travislane.svunes" ]; then + rm -rf "$HOME/.cache/dev.travislane.svunes" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes cache directory." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes cache directory already removed." + fi + + # Remove config directory + if [ -d "$HOME/.config/dev.travislane.svunes" ]; then + rm -rf "$HOME/.config/dev.travislane.svunes" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes config directory." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes config directory already removed." + fi + + # Remove Tauri Runtime Files + if [ -d "$HOME/.local/share/dev.travislane.svunes" ]; then + rm -rf "$HOME/.local/share/dev.travislane.svunes" + echo -e "${successGreen}[INFO]${noColor}: Removed Svunes Tauri runtime files." + else + echo -e "${infoCyan}[INFO]${noColor}: Svunes Tauri runtime files already removed." + fi + + update-desktop-database $HOME/.local/share/applications + echo -e "${successGreen}[INFO]${noColor}: Updated .desktop database." + + echo "" + + echo -e "${successGreen}[INFO]${noColor}: Successfully uninstalled Svunes. If this was because you ran into an issue, please open a GitHub issue so I can get it fixed!" +fi \ No newline at end of file diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json index 22ce7d4f..afcd887e 100644 --- a/src-tauri/tauri.conf.json +++ b/src-tauri/tauri.conf.json @@ -104,7 +104,9 @@ "resources": [], "shortDescription": "A robust, offline first Material Design music player.", "targets": [ - "msi" + "msi", + "appimage", + "deb" ], "licenseFile": "wix/short-license.txt", "createUpdaterArtifacts": true From b9d923b3915ca77aa8e45d403c7b789edfe6bdd7 Mon Sep 17 00:00:00 2001 From: Travis Lane <63308171+Tormak9970@users.noreply.github.com> Date: Thu, 15 Aug 2024 11:42:53 -0500 Subject: [PATCH 2/2] chore: fixed comment --- build-resources/appimage-installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build-resources/appimage-installer.sh b/build-resources/appimage-installer.sh index cdba6b39..ada3db79 100644 --- a/build-resources/appimage-installer.sh +++ b/build-resources/appimage-installer.sh @@ -8,7 +8,7 @@ successGreen='\033[1;96m' infoCyan='\033[1;92m' noColor='\033[0m' -comment="An offline first music player for your music library." +comment="A robust, offline first Material Design music player." uninstallComment="Uninstalls all files related to Svunes." currentVersion="v2.9.0"