Merge flatpak_app_exists and command_exists

This commit is contained in:
Jeevitha Kannan K S 2024-10-09 20:05:34 +05:30
parent 637fdc54d3
commit bcd1e4cacc
No known key found for this signature in database
GPG Key ID: 5904C34A2F7CE333
8 changed files with 15 additions and 83 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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}"