From bcd1e4caccb2fff23800c2d545417b5650e75672 Mon Sep 17 00:00:00 2001 From: Jeevitha Kannan K S Date: Wed, 9 Oct 2024 20:05:34 +0530 Subject: [PATCH] Merge flatpak_app_exists and command_exists --- .../Developer-tools/meld-setup.sh | 15 ++------------- core/tabs/applications-setup/bottles-setup.sh | 2 +- .../communication-apps/slack-setup.sh | 15 ++------------- .../communication-apps/zoom-setup.sh | 15 ++------------- .../office-suites/libreoffice.sh | 15 ++------------- .../office-suites/onlyoffice.sh | 15 ++------------- .../applications-setup/office-suites/wpsoffice.sh | 15 ++------------- core/tabs/common-script.sh | 6 ++---- 8 files changed, 15 insertions(+), 83 deletions(-) diff --git a/core/tabs/applications-setup/Developer-tools/meld-setup.sh b/core/tabs/applications-setup/Developer-tools/meld-setup.sh index aacafe27..031a09ae 100644 --- a/core/tabs/applications-setup/Developer-tools/meld-setup.sh +++ b/core/tabs/applications-setup/Developer-tools/meld-setup.sh @@ -2,20 +2,8 @@ . ../../common-script.sh -checkMeldInstallation() { - case "$PACKAGER" in - pacman|apt-get|nala) - command_exists meld - ;; - *) - checkFlatpak - flatpak_app_exists org.gnome.meld - ;; - esac -} - installMeld() { - if ! checkMeldInstallation; then + if ! command_exists org.gnome.meld && ! command_exists meld; then printf "%b\n" "${YELLOW}Installing Meld...${RC}" case "$PACKAGER" in pacman) @@ -25,6 +13,7 @@ installMeld() { "$ESCALATION_TOOL" "$PACKAGER" -y install meld ;; *) + checkFlatpak flatpak install -y flathub org.gnome.meld ;; esac diff --git a/core/tabs/applications-setup/bottles-setup.sh b/core/tabs/applications-setup/bottles-setup.sh index 56b42d5b..0b29bedb 100755 --- a/core/tabs/applications-setup/bottles-setup.sh +++ b/core/tabs/applications-setup/bottles-setup.sh @@ -3,7 +3,7 @@ . ../common-script.sh installBottles() { - if ! flatpak_app_exists "com.usebottles.bottles"; then + if ! command_exists com.usebottles.bottles; then printf "%b\n" "${YELLOW}Installing Bottles...${RC}" flatpak install -y flathub com.usebottles.bottles else diff --git a/core/tabs/applications-setup/communication-apps/slack-setup.sh b/core/tabs/applications-setup/communication-apps/slack-setup.sh index 0e6e6c54..24d6e532 100644 --- a/core/tabs/applications-setup/communication-apps/slack-setup.sh +++ b/core/tabs/applications-setup/communication-apps/slack-setup.sh @@ -2,26 +2,15 @@ . ../../common-script.sh -checkSlackInstallation() { - case "$PACKAGER" in - pacman) - command_exists slack - ;; - *) - checkFlatpak - flatpak_app_exists com.slack.Slack - ;; - esac -} - installSlack() { - if ! checkSlackInstallation; then + if ! command_exists com.slack.Slack && ! command_exists slack; then printf "%b\n" "${YELLOW}Installing Slack...${RC}" case "$PACKAGER" in pacman) "$AUR_HELPER" -S --needed --noconfirm slack-desktop ;; *) + checkFlatpak flatpak install -y flathub com.slack.Slack ;; esac diff --git a/core/tabs/applications-setup/communication-apps/zoom-setup.sh b/core/tabs/applications-setup/communication-apps/zoom-setup.sh index b3ace0d1..19d7e407 100644 --- a/core/tabs/applications-setup/communication-apps/zoom-setup.sh +++ b/core/tabs/applications-setup/communication-apps/zoom-setup.sh @@ -2,26 +2,15 @@ . ../../common-script.sh -checkZoomInstallation() { - case "$PACKAGER" in - pacman) - command_exists zoom - ;; - *) - checkFlatpak - flatpak_app_exists us.zoom.Zoom - ;; - esac -} - installZoom() { - if ! checkZoomInstallation; then + if ! command_exists us.zoom.Zoom && ! command_exists zoom; then printf "%b\n" "${YELLOW}Installing Zoom...${RC}" case "$PACKAGER" in pacman) "$AUR_HELPER" -S --needed --noconfirm zoom ;; *) + checkFlatpak flatpak install -y flathub us.zoom.Zoom ;; esac diff --git a/core/tabs/applications-setup/office-suites/libreoffice.sh b/core/tabs/applications-setup/office-suites/libreoffice.sh index 00184cea..1e149e9f 100644 --- a/core/tabs/applications-setup/office-suites/libreoffice.sh +++ b/core/tabs/applications-setup/office-suites/libreoffice.sh @@ -2,26 +2,15 @@ . ../common-script.sh -checkLibeOfficeInstallation() { - case "$PACKAGER" in - zypper|dnf) - checkFlatpak - flatpak_app_exists org.libreoffice.LibreOffice - ;; - *) - command_exists meld - ;; - esac -} - installLibreOffice() { - if ! checkLibeOfficeInstallation; then + if ! command_exists org.libreoffice.LibreOffice && ! command_exists libreoffice; then printf "%b\n" "${YELLOW}Installing Libre Office...${RC}" case "$PACKAGER" in apt-get|nala) "$ESCALATION_TOOL" "$PACKAGER" install -y libreoffice-core ;; zypper|dnf) + checkFlatpak flatpak install -y flathub org.libreoffice.LibreOffice ;; pacman) diff --git a/core/tabs/applications-setup/office-suites/onlyoffice.sh b/core/tabs/applications-setup/office-suites/onlyoffice.sh index 078789d0..7f524051 100644 --- a/core/tabs/applications-setup/office-suites/onlyoffice.sh +++ b/core/tabs/applications-setup/office-suites/onlyoffice.sh @@ -2,20 +2,8 @@ . ../common-script.sh -checkOnlyOfficeInstallation() { - case "$PACKAGER" in - zypper|dnf) - checkFlatpak - flatpak_app_exists org.onlyoffice.desktopeditors - ;; - *) - command_exists onlyoffice-desktopeditors - ;; - esac -} - installOnlyOffice() { - if ! checkOnlyOfficeInstallation; then + if ! command_exists org.onlyoffice.desktopeditors && ! command_exists onlyoffice-desktopeditors; then printf "%b\n" "${YELLOW}Installing Only Office..${RC}." case "$PACKAGER" in apt-get|nala) @@ -23,6 +11,7 @@ installOnlyOffice() { "$ESCALATION_TOOL" "$PACKAGER" install -y ./onlyoffice-desktopeditors_amd64.deb ;; zypper|dnf) + checkFlatpak flatpak install -y flathub org.onlyoffice.desktopeditors ;; pacman) diff --git a/core/tabs/applications-setup/office-suites/wpsoffice.sh b/core/tabs/applications-setup/office-suites/wpsoffice.sh index bf64c0b2..67cfb307 100644 --- a/core/tabs/applications-setup/office-suites/wpsoffice.sh +++ b/core/tabs/applications-setup/office-suites/wpsoffice.sh @@ -2,26 +2,15 @@ . ../common-script.sh -checkWpsOfficeInstallation() { - case "$PACKAGER" in - pacman) - command_exists wps - ;; - *) - checkFlatpak - flatpak_app_exists com.wps.Office - ;; - esac -} - installWpsOffice() { - if ! checkWpsOfficeInstallation; then + if ! command_exists com.wps.Office && ! command_exists wps; then printf "%b\n" "${YELLOW}Installing WPS Office...${RC}" case "$PACKAGER" in pacman) "$AUR_HELPER" -S --needed --noconfirm wps-office ;; *) + checkFlatpak flatpak install flathub com.wps.Office ;; esac diff --git a/core/tabs/common-script.sh b/core/tabs/common-script.sh index 9d5bc2f4..8d9a5a84 100644 --- a/core/tabs/common-script.sh +++ b/core/tabs/common-script.sh @@ -9,13 +9,11 @@ CYAN='\033[36m' GREEN='\033[32m' command_exists() { + ## Export flatpak binary paths. Should not be exported to PATH https://github.com/flatpak/flatpak/issues/3573#issuecomment-1330754720 + export XDG_DATA_DIRS=/home/jeeva/.local/share/flatpak/exports/share:/var/lib/flatpak/exports/share:/usr/local/share:$XDG_DATA_DIRS command -v "$1" >/dev/null 2>&1 } -flatpak_app_exists() { - flatpak info "$1" >/dev/null 2>&1 -} - checkFlatpak() { if ! command_exists flatpak; then printf "%b\n" "${YELLOW}Installing Flatpak...${RC}"