Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refact fix: Flatpak #705

Merged
merged 7 commits into from
Nov 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/Developer-tools/meld-setup.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#!/bin/sh -e

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

Check warning on line 3 in core/tabs/applications-setup/Developer-tools/meld-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/Developer-tools/meld-setup.sh:3:3: info: Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

installMeld() {
if ! command_exists meld; then
if ! command_exists org.gnome.meld && ! command_exists meld; then
printf "%b\n" "${YELLOW}Installing Meld...${RC}"
case "$PACKAGER" in
pacman)
Expand All @@ -13,7 +13,7 @@
"$ESCALATION_TOOL" "$PACKAGER" -y install meld
;;
*)
. ../setup-flatpak.sh
checkFlatpak
flatpak install -y flathub org.gnome.meld
;;
esac
Expand Down
12 changes: 4 additions & 8 deletions core/tabs/applications-setup/bottles-setup.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
#!/bin/sh -e

. ../common-script.sh

Check warning on line 3 in core/tabs/applications-setup/bottles-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/bottles-setup.sh:3:3: info: Not following: ../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

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 ! command_exists com.usebottles.bottles; then
printf "%b\n" "${YELLOW}Installing Bottles...${RC}"
flatpak install -y flathub com.usebottles.bottles
jeevithakannan2 marked this conversation as resolved.
Show resolved Hide resolved
else
printf "%b\n" "${GREEN}Bottles is already installed.${RC}"
fi
}

checkEnv
checkEscalationTool
checkFlatpak
installBottles
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh -e

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

Check warning on line 3 in core/tabs/applications-setup/communication-apps/slack-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/communication-apps/slack-setup.sh:3:3: info: Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

installSlack() {
if ! command_exists slack; 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
;;
*)
. ../setup-flatpak.sh
checkFlatpak
flatpak install -y flathub com.slack.Slack
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/communication-apps/zoom-setup.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh -e

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

Check warning on line 3 in core/tabs/applications-setup/communication-apps/zoom-setup.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/communication-apps/zoom-setup.sh:3:3: info: Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

installZoom() {
if ! command_exists zoom; 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
;;
*)
. ../setup-flatpak.sh
checkFlatpak
flatpak install -y flathub us.zoom.Zoom
;;
esac
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/office-suites/libreoffice.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh -e

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

Check warning on line 3 in core/tabs/applications-setup/office-suites/libreoffice.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/office-suites/libreoffice.sh:3:3: info: Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

installLibreOffice() {
if ! command_exists libreoffice; 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)
. ./setup-flatpak.sh
checkFlatpak
flatpak install -y flathub org.libreoffice.LibreOffice
;;
pacman)
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/office-suites/onlyoffice.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
#!/bin/sh -e

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

Check warning on line 3 in core/tabs/applications-setup/office-suites/onlyoffice.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/office-suites/onlyoffice.sh:3:3: info: Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

installOnlyOffice() {
if ! command_exists onlyoffice-desktopeditors; 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)
curl -O https://download.onlyoffice.com/install/desktop/editors/linux/onlyoffice-desktopeditors_amd64.deb
"$ESCALATION_TOOL" "$PACKAGER" install -y ./onlyoffice-desktopeditors_amd64.deb
;;
zypper|dnf)
. ./setup-flatpak.sh
checkFlatpak
flatpak install -y flathub org.onlyoffice.desktopeditors
;;
pacman)
Expand Down
4 changes: 2 additions & 2 deletions core/tabs/applications-setup/office-suites/wpsoffice.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
#!/bin/sh -e

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

Check warning on line 3 in core/tabs/applications-setup/office-suites/wpsoffice.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/office-suites/wpsoffice.sh:3:3: info: Not following: ../../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

installWpsOffice() {
if ! command_exists com.wps.Office; 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
;;
*)
. ./setup-flatpak.sh
checkFlatpak
flatpak install flathub com.wps.Office
;;
esac
Expand Down
44 changes: 6 additions & 38 deletions core/tabs/applications-setup/setup-flatpak.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
#!/bin/sh -e

. ../common-script.sh

Check warning on line 3 in core/tabs/applications-setup/setup-flatpak.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Not following: ../common-script.sh: openBinaryFile: does not exist (No such file or directory) Raw Output: ./core/tabs/applications-setup/setup-flatpak.sh:3:3: info: Not following: ../common-script.sh: openBinaryFile: does not exist (No such file or directory) (ShellCheck.SC1091)

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

checkEnv
checkEscalationTool
setup_flatpak
checkFlatpak
installExtra
36 changes: 32 additions & 4 deletions core/tabs/common-script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,38 @@
GREEN='\033[32m'

command_exists() {
for cmd in "$@"; do
command -v "$cmd" >/dev/null 2>&1 || return 1
done
return 0
for cmd in "$@"; do
export PATH=/home/jeeva/.local/share/flatpak/exports/bin:/var/lib/flatpak/exports/bin:$PATH

Check warning on line 13 in core/tabs/common-script.sh

View workflow job for this annotation

GitHub Actions / Shellcheck

[shellcheck] reported by reviewdog 🐶 Double quote to prevent globbing and word splitting. Raw Output: ./core/tabs/common-script.sh:13:91: info: Double quote to prevent globbing and word splitting. (ShellCheck.SC2086)
command -v "$cmd" >/dev/null 2>&1 || return 1
done
return 0
}

checkFlatpak() {
if ! command_exists flatpak; then
printf "%b\n" "${YELLOW}Installing Flatpak...${RC}"
case "$PACKAGER" in
pacman)
"$ESCALATION_TOOL" "$PACKAGER" -S --needed --noconfirm flatpak
;;
apk)
"$ESCALATION_TOOL" "$PACKAGER" add flatpak
;;
*)
"$ESCALATION_TOOL" "$PACKAGER" install -y flatpak
;;
esac
printf "%b\n" "${YELLOW}Adding Flathub remote...${RC}"
"$ESCALATION_TOOL" flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
printf "%b\n" "${YELLOW}Applications installed by Flatpak may not appear on your desktop until the user session is restarted...${RC}"
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() {
Expand Down
Loading