Skip to content

Commit

Permalink
Fix flatpak paths
Browse files Browse the repository at this point in the history
  • Loading branch information
jeevithakannan2 committed Sep 30, 2024
1 parent a9a678f commit adad259
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 51 deletions.
12 changes: 4 additions & 8 deletions core/tabs/applications-setup/bottles-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,15 @@
. ../common-script.sh

installBottles() {
if ! command_exists flatpak; then
printf "%b\n" "${YELLOW}Installing Bottles...${RC}"
case "$PACKAGER" in
*)
. ./setup-flatpak.sh
flatpak install -y flathub com.usebottles.bottles
;;
esac
if ! flatpak_app_exists "com.usebottles.bottles"; then
printf "%b\n" "${YELLOW}Installing Bottles...${RC}"
flatpak install -y flathub com.usebottles.bottles
else
printf "%b\n" "${GREEN}Bottles is already installed.${RC}"
fi
}

checkEnv
checkEscalationTool
checkFlatpak
installBottles
15 changes: 13 additions & 2 deletions core/tabs/applications-setup/communication-apps/slack-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@

. ../../common-script.sh

checkSlackInstallation() {
case "$PACKAGER" in
pacman)
command_exists slack
;;
*)
checkFlatpak
flatpak_app_exists com.slack.Slack
;;
esac
}

installSlack() {
if ! command_exists slack; then
if ! checkSlackInstallation; then
printf "%b\n" "${YELLOW}Installing Slack...${RC}"
case "$PACKAGER" in
pacman)
"$AUR_HELPER" -S --needed --noconfirm slack-desktop
;;
*)
. ./setup-flatpak.sh
flatpak install -y flathub com.slack.Slack
;;
esac
Expand Down
15 changes: 13 additions & 2 deletions core/tabs/applications-setup/communication-apps/zoom-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,26 @@

. ../../common-script.sh

checkZoomInstallation() {
case "$PACKAGER" in
pacman)
command_exists zoom
;;
*)
checkFlatpak
flatpak_app_exists us.zoom.Zoom
;;
esac
}

installZoom() {
if ! command_exists zoom; then
if ! checkZoomInstallation; then
printf "%b\n" "${YELLOW}Installing Zoom...${RC}"
case "$PACKAGER" in
pacman)
"$AUR_HELPER" -S --needed --noconfirm zoom
;;
*)
. ./setup-flatpak.sh
flatpak install -y flathub us.zoom.Zoom
;;
esac
Expand Down
2 changes: 1 addition & 1 deletion core/tabs/applications-setup/office-suite-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -200,4 +200,4 @@ officeSuiteSetup() {
checkEnv
checkEscalationTool
checkAURHelper
officeSuiteSetup
officeSuiteSetup
44 changes: 6 additions & 38 deletions core/tabs/applications-setup/setup-flatpak.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

. ../common-script.sh

# Used to detect the desktop environment, Only used for the If statement in the setup_flatpak function.
# Perhaps this should be moved to common-script.sh later on?
detect_de() {
checkDE() {
if [ -n "$XDG_CURRENT_DESKTOP" ]; then
case "$XDG_CURRENT_DESKTOP" in
*GNOME*)
Expand All @@ -17,42 +15,11 @@ detect_de() {
fi
}

# Install Flatpak if not already installed.
setup_flatpak() {
if ! command_exists flatpak; then
printf "%b\n" "${YELLOW}Installing Flatpak...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
;;
esac
printf "%b\n" "Adding Flathub remote..."
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
else
if command_exists flatpak; then
if ! flatpak remotes | grep -q "flathub"; then
printf "%b" "${YELLOW}Detected Flatpak package manager but Flathub remote is not added. Would you like to add it? (y/N): ${RC}"
read -r add_remote
case "$add_remote" in
[Yy]*)
printf "%b\n" "Adding Flathub remote..."
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
;;
esac
else
# Needed mostly for systems without a polkit agent running (Error: updating: Unable to connect to system bus)
printf "%b\n" "${GREEN}Flathub already setup. You can quit.${RC}"
fi
fi
fi

installExtra() {
if [ "$PACKAGER" = "apt-get" ] || [ "$PACKAGER" = "nala" ]; then
detect_de
checkDE
# Only used for Ubuntu GNOME. Ubuntu GNOME doesnt allow flathub to be added as a remote to their store.
# So in case the user wants to use a GUI siftware manager they can setup it here
# So in case the user wants to use a GUI software manager they can setup it here
if [ "$DE" = "GNOME" ]; then
printf "%b" "${YELLOW}Detected GNOME desktop environment. Would you like to install GNOME Software plugin for Flatpak? (y/N): ${RC}"
read -r install_gnome
Expand All @@ -72,4 +39,5 @@ setup_flatpak() {

checkEnv
checkEscalationTool
setup_flatpak
checkFlatpak
installExtra
27 changes: 27 additions & 0 deletions core/tabs/common-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@ command_exists() {
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}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
;;
esac
printf "%b\n" "Adding Flathub remote..."
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
else
if ! flatpak remotes | grep -q "flathub"; then
printf "%b\n" "${YELLOW}Adding Flathub remote...${RC}"
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
else
printf "%b\n" "${CYAN}Flatpak is installed${RC}"
fi
fi
}

checkAURHelper() {
## Check & Install AUR helper
if [ "$PACKAGER" = "pacman" ]; then
Expand Down

0 comments on commit adad259

Please sign in to comment.