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

fix: improve Flatpak installation script for better user interaction … #1793

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
60 changes: 58 additions & 2 deletions Scripts/.extra/install_fpk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,79 @@
#|-/ /--| Prasanth Rangan |-/ /--|#
#|/ /---+-----------------------------------+/ /---|#

# Define the base and script directories
baseDir=$(dirname "$(realpath "$0")")
scrDir=$(dirname "$(dirname "$(realpath "$0")")")

# Source global functions
source "${scrDir}/global_fn.sh"
if [ $? -ne 0 ]; then
echo "Error: unable to source global_fn.sh..."
exit 1
fi

# Check if Flatpak is installed, and install it if not
if ! pkg_installed flatpak; then
echo "Flatpak not found. Installing Flatpak..."
sudo pacman -S flatpak
fi

# Add the Flathub repository if not already added
flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
flats=$(awk -F '#' '{print $1}' "${baseDir}/custom_flat.lst" | sed 's/ //g' | xargs)

flatpak install --user -y flathub ${flats}
# Read and process the Flatpak list
echo "Reading Flatpak list..."
flats=$(awk -F '#' '{print $1}' "${baseDir}/custom_flat.lst" | sed 's/ //g' | grep -v '^$')

# Check if the list is empty
if [ -z "$flats" ]; then
echo "No Flatpak applications found in the list."
exit 1
fi

# Prepare a menu for user selection
echo "Please select the Flatpak applications you want to install:"
select flatpak in $flats "Install All" "Cancel"; do
case $flatpak in
"Install All")
selected_flats="$flats"
break
;;
"Cancel")
echo "Operation cancelled."
exit 0
;;
*)
if [[ " $flats " == *" $flatpak "* ]]; then
selected_flats="$flatpak"
break
else
echo "Invalid selection."
;;
fi
;;
esac
done

# Confirm installation
echo "You have selected the following Flatpak applications for installation:"
echo "$selected_flats"
read -p "Do you want to proceed with the installation? (y/n): " confirm
if [[ $confirm != "y" && $confirm != "Y" ]]; then
echo "Installation cancelled."
exit 0
fi

# Install selected Flatpak applications
echo "Installing Flatpak applications..."
for flat in $selected_flats; do
flatpak install --user -y flathub $flat
done

# Remove unused Flatpak runtimes and dependencies
flatpak remove --unused

# Set Flatpak overrides for GTK themes and icons
gtkTheme=$(gsettings get org.gnome.desktop.interface gtk-theme | sed "s/'//g")
gtkIcon=$(gsettings get org.gnome.desktop.interface icon-theme | sed "s/'//g")

Expand All @@ -31,3 +85,5 @@ flatpak --user override --filesystem=~/.icons

flatpak --user override --env=GTK_THEME=${gtkTheme}
flatpak --user override --env=ICON_THEME=${gtkIcon}

echo "Flatpak installation complete."