Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
simplify install functions
Browse files Browse the repository at this point in the history
  • Loading branch information
snwh committed May 21, 2018
1 parent f49ccae commit 7ff5b89
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 111 deletions.
1 change: 1 addition & 0 deletions data/favs.list
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ gnome-software-plugin-flatpak
gnome-software-plugin-snap
gnome-sushi
gnome-tweak-tool
inkscape
nautilus
sparkleshare
transmission
96 changes: 45 additions & 51 deletions functions/install_flatpak_apps
Original file line number Diff line number Diff line change
@@ -1,66 +1,60 @@
#!/bin/bash

# install gimp
function install_flatpak_gimp {
# install app from flathub repository
function install_flathub_app() {
echo_message header "Starting 'install_flathub_app' function..."
# check if flathub repo is added
check_flatpak_repo "flathub" "https://flathub.org/repo/flathub.flatpakrepo" install_flatpak_apps
#install_flatpak_package "Name" "source" "com.package.Name" return_function
install_flatpak_package "GIMP" "flathub" "org.gimp.GIMP" install_flatpak_apps
install_flatpak_package $1 "flathub" $2 install_flatpak_apps
}

# install peek
function install_flatpak_peek {
# check if flathub repo is added
check_flatpak_repo "flathub" "https://flathub.org/repo/flathub.flatpakrepo" install_flatpak_apps
#install_flatpak_package "Name" "source" "com.package.Name" return_function
install_flatpak_package "Peek" "flathub" "com.uploadedlobster.peek" install_flatpak_apps
}

# install riot
function install_flatpak_riot {
# check if flathub repo is added
check_flatpak_repo "flathub" "https://flathub.org/repo/flathub.flatpakrepo" install_flatpak_apps
#install_flatpak_package "Name" "source" "com.package.Name" return_function
install_flatpak_package "Riot" "flathub" "im.riot.Riot" install_flatpak_apps
}

# install steam
function install_flatpak_steam {
# check if flathub repo is added
check_flatpak_repo "flathub" "https://flathub.org/repo/flathub.flatpakrepo" install_flatpak_apps
#install_flatpak_package "Name" "source" "com.package.Name" return_function
install_flatpak_package "Steam" "flathub" "com.valvesoftware.Steam" install_flatpak_apps
}


# Install Flatpak Applications
function install_flatpak_apps {
# check if flatpak is installed
# check if 'flatpak' is installed
check_package "flatpak" main
# install
NAME="Flatpak Applications"
echo_message title "Starting installation of ${NAME,,}..."
# Draw window
FLATPAKS=$(eval `resize` && whiptail \
--notags \
--title "Install $NAME" \
--menu "\nWhat ${NAME,,} would you like to install?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'install_flatpak_gimp' 'GIMP' \
'install_flatpak_peek' 'Peek' \
'install_flatpak_riot' 'Riot' \
'install_flatpak_steam' 'Steam' \
3>&1 1>&2 2>&3)
status="0"
while [ "$status" -eq 0 ]; do
# Draw window
FLATPAKS=$(eval `resize` && whiptail \
--notags \
--title "Install $NAME" \
--menu "\nWhat ${NAME,,} would you like to install?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'install_flatpak_gimp' 'GIMP' \
'install_flatpak_peek' 'Peek' \
'install_flatpak_peek' 'Riot' \
'install_flatpak_steam' 'Steam' \
3>&1 1>&2 2>&3)

# check exit status
if [ $? = 0 ]; then
echo_message header "Starting '$FLATPAKS' function..."
$FLATPAKS
else
# Cancelled
echo_message info "Installation of ${NAME} cancelled."
main
fi
case "${FLATPAKS}" in
install_flatpak_gimp)
# install GIMP
install_flathub_app "GIMP" "org.gimp.GIMP"
;;
install_flatpak_peek)
# install Peek
install_flathub_app "Peek" "com.uploadedlobster.peek"
;;
install_flatpak_riot)
# install Riot chat
install_flathub_app "Riot" "im.riot.Riot"
;;
install_flatpak_steam)
# install Steam
install_flathub_app "Steam" "com.valvesoftware.Steam"
;;
*)
# cancel
echo_message info "Returning..."
status=1
main
;;
esac
done
}
10 changes: 5 additions & 5 deletions functions/install_functions
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function install_flatpak_package() {
echo_message info "${1} is not installed. Installing..."
if (whiptail \
--title "Install ${1}" \
--yesno "The ${1} Flatpak package is not installed. \n\nProceed with installation of '${3}'?" 10 64) then
--yesno "The flatpak package for ${1} is not installed. \n\nProceed with installation of '${3}'?" 10 64) then
# Install
echo_message info "Installing flatpak '${3}'..."
flatpak install -y ${2} ${3}
Expand All @@ -141,7 +141,7 @@ function install_flatpak_package() {
fi
else
# Already installed
echo_message info "${3} is already installed."
echo_message info "Flatpak '${3}' is already installed."
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 64
$4
fi
Expand All @@ -151,11 +151,11 @@ function install_flatpak_package() {
function install_snap_package() {
# echo_message header "Starting 'install_snap_package' function..."
# If package is not installed
if [ $(snap list | grep $1 &> /dev/null: echo $?) = 1 ]; then
if [ $(snap list | grep $1 &> /dev/null; echo $?) = 1 ]; then
echo_message info "${1} is not installed. Installing..."
if (whiptail \
--title "Install ${1^}" \
--yesno "The Snap package for ${1^} is not installed. \n\nProceed with installation of '${1}'?" 10 64) then
--yesno "The snap package for ${1^} is not installed. \n\nProceed with installation of '${1}'?" 10 64) then
# Install
echo_message info "Installing snap '${1}'..."
# Admin privileges
Expand All @@ -171,7 +171,7 @@ function install_snap_package() {
fi
else
# Already installed
echo_message info "${1} is already installed."
echo_message info "Snap '${1}' is already installed."
whiptail --title "Installed" --msgbox "${1^} is already installed." 8 64
$3
fi
Expand Down
101 changes: 46 additions & 55 deletions functions/install_snap_apps
Original file line number Diff line number Diff line change
@@ -1,62 +1,53 @@
#!/bin/bash

# install Atom from snap
function install_snap_atom {
#install_snap_package "Name" "package"
install_snap_package "atom" install_snap_apps
}

# install Inkscape from snap
function install_snap_inkscape {
#install_snap_package "Name" "package"
install_snap_package "inkscape" install_snap_apps
}

# install Slack from snap
function install_snap_slack {
#install_snap_package "Name" "package"
install_snap_package "slack" install_snap_apps
}

# install Spotify from snap
function install_snap_spotify {
#install_snap_package "Name" "package"
install_snap_package "spotify" install_snap_apps
}

# install Slack from snap
function install_snap_sublime_text {
#install_snap_package "Name" "package"
install_snap_package "sublime-text" install_snap_apps
}


# Install Snap Applications
function install_snap_apps {
NAME="Snap Applications"
echo_message title "Starting installation of ${NAME,,}..."
# Draw window
SNAPS=$(eval `resize` && whiptail \
--notags \
--title "Install $NAME" \
--menu "\nWhat ${NAME,,} would you like to install?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'install_snap_atom' 'Atom' \
'install_snap_inkscape' 'Inkscape' \
'install_snap_slack' 'Slack' \
'install_snap_spotify' 'Spotify' \
'install_snap_sublime_text' 'Sublime Text' \
3>&1 1>&2 2>&3)

# check exit status
if [ $? = 0 ]; then
echo_message header "Starting '$SNAPS' function..."
$SNAPS
else
# Cancelled
echo_message info "Installation of ${NAME,,} cancelled."
main
fi
status="0"
while [ "$status" -eq 0 ]; do
# Draw window
SNAPS=$(eval `resize` && whiptail \
--notags \
--title "Install $NAME" \
--menu "\nWhat ${NAME,,} would you like to install?" \
--ok-button "Install" \
--cancel-button "Go Back" \
$LINES $COLUMNS $(( $LINES - 12 )) \
'install_snap_atom' 'Atom' \
'install_snap_inkscape' 'Inkscape' \
'install_snap_slack' 'Slack' \
'install_snap_spotify' 'Spotify' \
'install_snap_sublime' 'Sublime Text' \
3>&1 1>&2 2>&3)

case "${SNAPS}" in
install_snap_atom)
# install Atom text editor
install_snap_package "atom" install_snap_apps
;;
install_snap_inkscape)
# install Inkscape
install_snap_package "inkscape" install_snap_apps
;;
install_snap_slack)
# install Slack
install_snap_package "slack" install_snap_apps
;;
install_snap_spotify)
# install Spotify
install_snap_package "spotify" install_snap_apps
;;
install_snap_sublime)
# install Sublime Text
install_snap_package "sublime-text" install_snap_apps
;;
*)
# cancel
echo_message info "Returning..."
status=1
main
;;
esac
done
}

0 comments on commit 7ff5b89

Please sign in to comment.