Finish transition to zenity

This commit is contained in:
2024-08-07 16:03:01 +01:00
parent b622f39b92
commit 28bb428976

View File

@@ -1,24 +1,40 @@
#! /bin/bash #! /bin/bash
# Sudo auth
auth() {
echo "$sudopass" | sudo -S -k $*
}
export HISTIGNORE='*sudo -S*'
for (( ; ; )); do
sudopass=$(zenity --password)
if [ -z "${sudopass}" ]; then
exit
fi
auth echo "Test sudo password."
if [[ $? == 0 ]]; then
break
fi
done
if ! command -v zenity; then if ! command -v zenity; then
sudo apt-get install zenity -y auth apt-get install zenity -y
fi fi
# Update System # Update System
( (
sudo apt-get update auth apt-get update
echo "20" echo "20"
echo "# Updating distro packages..." echo "# Updating distro packages..."
sudo apt-get dist-upgrade -y auth apt-get dist-upgrade -y
echo "40" echo "40"
echo "# Updating installed packages..." echo "# Updating installed packages..."
sudo apt-get upgrade -y auth apt-get upgrade -y
echo "60" echo "60"
echo "# Cleaning cache..." echo "# Cleaning cache..."
sudo apt-get clean auth apt-get clean
echo "80" echo "80"
echo "# Removing unused dependencies..." echo "# Removing unused dependencies..."
sudo apt-get autoremove -y auth apt-get autoremove -y
echo "100" echo "100"
) | ) |
zenity --progress --title="Update System" --text="Updating repositories..." --percentage=0 --no-cancel zenity --progress --title="Update System" --text="Updating repositories..." --percentage=0 --no-cancel
@@ -30,7 +46,7 @@ zenity --question \
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
( (
sudo apt-get install -y htop fzf git wget curl bash-completion auth apt-get install -y htop fzf git wget curl bash-completion
echo "20" echo "20"
echo "# Copying dotfiles..." echo "# Copying dotfiles..."
cp -vrf config-files/.* $HOME cp -vrf config-files/.* $HOME
@@ -54,13 +70,13 @@ zenity --question \
if [[ $? == 0 ]]; then if [[ $? == 0 ]]; then
( (
sudo apt install -y flatpak auth apt-get install -y flatpak
echo "30" echo "30"
echo "# Install the gnome-software plugin..." echo "# Install the gnome-software plugin..."
sudo apt install -y gnome-software-plugin-flatpak auth apt-get install -y gnome-software-plugin-flatpak
echo "50" echo "50"
echo "# Add Flathub..." echo "# Add Flathub..."
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo auth flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
echo "75" echo "75"
echo "# Installing Adw GTK3 theme for flatpak apps..." echo "# Installing Adw GTK3 theme for flatpak apps..."
flatpak install org.gtk.Gtk3theme.adw-gtk3 org.gtk.Gtk3theme.adw-gtk3-dark flatpak install org.gtk.Gtk3theme.adw-gtk3 org.gtk.Gtk3theme.adw-gtk3-dark
@@ -69,16 +85,16 @@ if [[ $? == 0 ]]; then
zenity --progress --title="Enabling Flatpak" --text="Installing Flatpak..." --percentage=0 --no-cancel zenity --progress --title="Enabling Flatpak" --text="Installing Flatpak..." --percentage=0 --no-cancel
fi fi
# Apps # Debian Apps
options=( options=(
FALSE "Install Neovim" FALSE "Install Neovim"
FALSE "Install Zed" FALSE "Install Zed"
FALSE "Install Ollama" FALSE "Install Ollama"
FALSE "Install GitHub CLI" FALSE "Install GitHub CLI"
FALSE "Install Tailscale (VPN)" FALSE "Install Tailscale"
FALSE "Install Syncthing" FALSE "Install Firefox + Adw theme"
) )
checkbox=$(zenity --list --checklist \ checkbox=$(zenity --list --checklist --height=500\
--title="Install Apps" \ --title="Install Apps" \
--column="Select" \ --column="Select" \
--column="Tasks" "${options[@]}") --column="Tasks" "${options[@]}")
@@ -87,7 +103,7 @@ readarray -td '|' choices < <(printf '%s' "$checkbox")
for selection in "${choices[@]}"; do for selection in "${choices[@]}"; do
if [ "$selection" = "Install Neovim" ]; then if [ "$selection" = "Install Neovim" ]; then
( (
sudo apt install -y ninja-build gettext cmake unzip curl build-essential auth apt install -y ninja-build gettext cmake unzip curl build-essential
echo "30" echo "30"
git clone https://github.com/neovim/neovim --depth 1 git clone https://github.com/neovim/neovim --depth 1
echo "50" echo "50"
@@ -96,7 +112,7 @@ for selection in "${choices[@]}"; do
echo "60" echo "60"
make CMAKE_BUILD_TYPE=RelWithDebInfo make CMAKE_BUILD_TYPE=RelWithDebInfo
echo "80" echo "80"
sudo make install auth make install
cd .. cd ..
rm -rf neovim rm -rf neovim
echo "100" echo "100"
@@ -124,99 +140,89 @@ for selection in "${choices[@]}"; do
fi fi
fi fi
# ------ TODO ---------
if [ "$selection" = "########" ]; then
# Firefox Theme
dialog --erase-on-exit \
--backtitle "$BACKTITLE" \
--title "Install the Adwaita Firefox theme?" \
--yesno "OPEN FIREFOX BEFORE INSTALLING! The theme mimics GNOME Web and will be installed using the script provided by the theme on GitHub." 10 40
if [ "$?" -eq 0 ]; then
curl -s -o- https://raw.githubusercontent.com/rafaelmardojai/firefox-gnome-theme/master/scripts/install-by-curl.sh | bash
fi
fi
if [ "$selection" = "Install GitHub CLI" ]; then if [ "$selection" = "Install GitHub CLI" ]; then
clear (
echo "----------------------" auth apt-get install wget -y
echo "--- Install GH CLI ---" echo "20"
echo "----------------------" auth mkdir -p -m 755 /etc/apt/keyrings
echo auth rm -f /etc/apt/sources.list.d/github-cli.list
echo wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | auth tee /etc/apt/keyrings/githubcli-archive-keyring.gpg
echo "40"
sudo apt install wget -y auth chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg
sudo mkdir -p -m 755 /etc/apt/keyrings echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | auth tee /etc/apt/sources.list.d/github-cli.list
sudo rm -f /etc/apt/sources.list.d/github-cli.list auth apt-get update
wget -qO- https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo tee /etc/apt/keyrings/githubcli-archive-keyring.gpg echo "60"
sudo chmod go+r /etc/apt/keyrings/githubcli-archive-keyring.gpg auth apt-get install gh -y
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list echo "100"
sudo apt update ) |
sudo apt install gh -y zenity --progress --title="GitHub CLI" --text="Installing GitHub CLI..." --percentage=0 --no-cancel
fi fi
if [ "$selection" = "Install Apps (Enables Flatpak)" ]; then if [ "$selection" = "Install Tailscale" ]; then
clear (
echo "----------------------------"
echo "--- Install Applications ---"
echo "----------------------------"
echo
echo
dialog --erase-on-exit \
--backtitle "$BACKTITLE" \
--checklist "Select Apps to install." 30 90 5 \
"io.github.mrvladus.List" "Errands (Tasks)" "on"\
"io.gitlab.news_flash.NewsFlash" "Newsflash (RSS)" "on"\
"org.gnome.gitlab.somas.Apostrophe" "Apostrophe (Markdown Editor)" "on"\
"org.gnome.World.Secrets" "Secrets (Password manager)" "on"\
"org.gnome.Polari" "Polari (IRC)" "off" \
"org.gnome.Fractal" "Fractal (Matrix)" "on"\
"so.libdb.dissent" "Dissent (Discord)" "on"\
"io.gitlab.adhami3310.Impression" "Impression (Disk image creator)" "on"\
"org.gnome.Builder" "Builder (IDE)" "on"\
"org.gnome.design.AppIconPreview" "App Icon Preview" "on"\
"org.gnome.design.IconLibrary" "Icon Library" "on"\
"org.gnome.design.Palette" "Color Palette" "on"\
"org.gnome.design.SymbolicPreview" "Symbolic Preview" "on"\
"org.gnome.design.Typography" "Typography" "on"\
"re.sonny.Workbench" "Workbench" "on"\
"org.prismlauncher.PrismLauncher" "Prism Launcher" "off" 2> choice.tmp
app_menu=$( cat choice.tmp )
rm choice.tmp
for app in $app_menu; do
echo "Installing $app..."
flatpak install -y flathub $app
done
fi
if [ "$selection" = "Install Tailscale (VPN)" ]; then
clear
echo "-------------------------"
echo "--- Install Tailscale ---"
echo "-------------------------"
echo
echo
curl -fsSL https://tailscale.com/install.sh | sh curl -fsSL https://tailscale.com/install.sh | sh
sudo tailscale up echo "80"
auth tailscale up
echo "100"
) |
zenity --progress --title="Tailscale" --text="Installing Tailscale..." --percentage=0 --no-cancel
fi fi
if [ "$selection" = "Install Syncthing" ]; then if [ "$selection" = "Install Firefox + Adw theme" ]; then
clear (
echo "-------------------------" auth apt install -y firefox-esr
echo "--- Install Syncthing ---" echo "60"
echo "-------------------------" firefox &
echo sleep 5
echo echo "80"
echo "# Applying Adw theme..."
sudo apt install syncthing curl -s -o- https://raw.githubusercontent.com/rafaelmardojai/firefox-gnome-theme/master/scripts/install-by-curl.sh | bash
systemctl --user enable syncthing.service echo "100"
systemctl --user start syncthing.service ) |
xdg-open "http://127.0.0.1:8384/" & zenity --progress --title="Firefox" --text="Installing Firefox..." --percentage=0 --no-cancel
fi fi
done done
# Flatpak Apps
if command -v flatpak; then
options=(
FALSE "io.github.mrvladus.List" "Errands (Tasks)"
FALSE "io.gitlab.news_flash.NewsFlash" "Newsflash (RSS)"
FALSE "org.gnome.gitlab.somas.Apostrophe" "Apostrophe (Markdown Editor)"
FALSE "org.gnome.World.Secrets" "Secrets (Password manager)"
FALSE "org.gnome.Polari" "Polari (IRC)"
FALSE "org.gnome.Fractal" "Fractal (Matrix)"
FALSE "so.libdb.dissent" "Dissent (Discord)"
FALSE "io.gitlab.adhami3310.Impression" "Impression (Disk image creator)"
FALSE "org.gnome.Builder" "Builder (IDE)"
FALSE "org.gnome.design.AppIconPreview" "App Icon Preview"
FALSE "org.gnome.design.IconLibrary" "Icon Library"
FALSE "org.gnome.design.Palette" "Color Palette"
FALSE "org.gnome.design.SymbolicPreview" "Symbolic Preview"
FALSE "org.gnome.design.Typography" "Typography"
FALSE "re.sonny.Workbench" "Workbench"
FALSE "org.prismlauncher.PrismLauncher" "Prism Launcher"
FALSE "md.obsidian.Obsidian" "Obsidian"
)
checkbox=$(zenity --list --checklist --width=800 --height=600 \
--title="Install Apps" \
--column="Select" \
--column="App ID"\
--column="App Name" "${options[@]}")
readarray -td '|' choices < <(printf '%s' "$checkbox")
declare -i app_counter=0
declare -i app_total="${#choices[@]}"
for app in "${choices[@]}"; do
app_counter+=1
echo "Installing $app ($app_counter/$app_total)..."
zenity --notification --icon="info" --text="Installing $app ($app_counter/$app_total)..."
flatpak install -y flathub $app
if [[ $? == 0 ]]; then
zenity --notification --icon="info" --text="$app is now installed."
else
zenity --notification --icon="error" --text="$app failed to install."
fi
done
fi