Removed un-necessary desktop-file-install's and setup flagged conditional that will handle installing/updating the desktop file if needed

This commit is contained in:
Tristan Ancelet 2023-12-01 12:22:49 -06:00
parent 2b6efc9a5d
commit 22669044db

View File

@ -7,14 +7,14 @@ ACTION=""
DOWNLOAD_URL='https://discord.com/api/download/stable?platform=linux&format=tar.gz'
VERSION_REGEX='[0-9]+\.[0-9]+\.[0-9]+'
INSTALL_DIR=~/.opt
LOCAL_APPLICATION_DIR=~/.local/share/applications
EXISTING_INSTALL=$INSTALL_DIR/Discord
BUILD_FILE=$EXISTING_INSTALL/resources/build_info.json
DESKTOP_FILE=$EXISTING_INSTALL/discord.desktop
INSTALLED_DESKTOP_FILE=$LOCAL_APPLICATION_DIR/discord.desktop
PACKAGE_DOWNLOAD_URL_BASE='https://dl.discordapp.net/apps/linux/{VERSION}/discord-{VERSION}.tar.gz'
ICON_DIR=~/.local/share/icons
DESKTOP_FILE_INSTALLED=0
LOCAL_APPLICATION_DIR=~/.local/share/applications
[[ -f /usr/share/applications/discord.desktop ]] && DESKTOP_FILE_INSTALLED=1
DESKTOP_FILE_NEEDS_UPDATE=0
# END: Variables
@ -110,7 +110,6 @@ function do_install() {
[[ ! -d $ICON_DIR ]] && mkdir -p $ICON_DIR
cp $EXISTING_INSTALL/discord.png $ICON_DIR/
sudo desktop-file-isntall $DESKTOP_FILE
}
function do_upgrade(){
@ -188,8 +187,21 @@ esac
# BEGIN: End Work Check
## If discord isn't already setup in your global applications, go ahead and install the desktop file
if [[ ! -f $LOCAL_APPLICATION_DIR/discord.desktop ]]; then
if [[ ! -f $INSTALLED_DESKTOP_FILE ]]; then
log "Desktop file not found in the global applications dir ($LOCAL_APPLICATION_DIR) installing now"
DESKTOP_FILE_NEEDS_UPDATE=1
else
# If there is a change for any reason update it
if [[ "$(<$DESKTOP_FILE)" != "$(<$INSTALLED_DESKTOP_FILE)" ]]; then
DESKTOP_FILE_NEEDS_UPDATE=1
fi
fi
if [[ $DESKTOP_FILE_NEEDS_UPDATE -eq 1 ]]; then
log "Updating/Installing desktop file"
desktop-file-install --dir=$LOCAL_APPLICATION_DIR $DESKTOP_FILE
if [[ $? -ne 0 ]]; then