Better installer and colors for most scripts.

This commit is contained in:
2024-01-07 23:00:07 +00:00
parent ba5810c091
commit 566a8fcbbc
2 changed files with 128 additions and 57 deletions

View File

@@ -1,10 +1,12 @@
#! /bin/bash
source ./scripts/p.sh # Universal package manager
source ./scripts/p.sh
source ./scripts/color.sh
dist=$(d)
if [ $dist == 0 ]; then
echo "ERROR - Distro not supported."
echo -e "${RED}[E] Distro not supported.${ENDCOLOR}"
return 1
fi
@@ -21,94 +23,158 @@ function ask() {
}
# Upgrade
echo "Updating packages..."
echo -e "${GREEN}[+] Updating packages...${ENDCOLOR}"
p
p i git
# Install git
if p c git &>/dev/null; then
echo -e "${GREEN}[i] git is installed.${ENDCOLOR}"
else
echo -e "${GREEN}[+] Installing git...${ENDCOLOR}"
p i git
echo -e "${GREEN}[i] git installed.${ENDCOLOR}"
fi
# Mirrors
if [ $dist == 2 ]; then
if ask "Choose best mirrors (LONG TIME)?"; then
sudo pacman -S reflector
echo -e "${GREEN}[+] Choosing mirrors...${ENDCOLOR}"
p i reflector
sudo reflector --sort rate -p https --save /etc/pacman.d/mirrorlist --verbose
read -p "Press enter to continue."
echo -e "${GREEN}[i] New mirrors applied.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi
# Install paru
if [ $dist == 2 ]; then
paru=$(pacman -Q paru)
if [[ -n "$paru" ]]; then
echo -e "\e[32m[I] Paru is already installed.\e[0m"
if p c paru &>/dev/null; then
echo -e "${GREEN}[i] Paru is installed.${ENDCOLOR}"
else
echo -e "${GREEN}[+] Installing paru...${ENDCOLOR}"
sudo pacman -S --needed base-devel
git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si
cd ..
rm -rf paru
echo -e "${GREEN}[i] Paru installed.${ENDCOLOR}"
fi
read -p "Press enter to continue."
fi
# Enable bluetooth support
if [ $dist == 2 ]; then
if ask "Enable bluetooth?"; then
sudo pacman -S bluez bluez-utils
sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service
if p c bluetooth &>/dev/null; then
echo -e "${GREEN}[i] Bluetooth is enabled.${ENDCOLOR}"
else
if ask "Enable bluetooth?"; then
echo -e "${GREEN}[+] Installing bluetooth support...${ENDCOLOR}"
sudo pacman -S bluez bluez-utils
sudo systemctl start bluetooth.service
sudo systemctl enable bluetooth.service
echo -e "${GREEN}[i] Bluetooth enabled.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi
fi
# Enable printer support
if [ $dist == 2 ]; then
if ask "Enable CUPS (printer)?"; then
sudo pacman -S cups
sudo systemctl start cups
sudo systemctl start cups.service
sudo systemctl enable cups
sudo systemctl enable cups.service
if p c cups &>/dev/null; then
echo -e "${GREEN}[i] CUPS is enabled.${ENDCOLOR}"
else
if ask "Enable CUPS (printer)?"; then
echo -e "${GREEN}[+] Installing CUPS...${ENDCOLOR}"
sudo pacman -S cups
sudo systemctl start cups
sudo systemctl start cups.service
sudo systemctl enable cups
sudo systemctl enable cups.service
echo -e "${GREEN}[i] CUPS enabled.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi
fi
# Install Icon theme
echo "Installing Papirus Icon Theme..."
wget -qO- https://git.io/papirus-icon-theme-install | sh
gsettings set org.gnome.desktop.interface icon-theme 'Papirus Dark'
if ls /usr/share/icons/ | grep -i Papirus &>/dev/null; then
echo -e "${GREEN}[i] Icon theme is installed.${ENDCOLOR}"
else
echo -e "${GREEN}[+] Downloading Papirus icon theme...${ENDCOLOR}"
wget -qO- https://git.io/papirus-icon-theme-install | sh
gsettings set org.gnome.desktop.interface icon-theme 'Papirus Dark'
echo -e "${GREEN}[i] Theme is set.${ENDCOLOR}"
fi
# Install Cursor theme
echo "Installing Cursor Theme..."
p i bibata-cursor-theme
gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic'
if ls /usr/share/icons/ | grep -i bibata &>/dev/null; then
echo -e "${GREEN}[i] Cursor theme is installed.${ENDCOLOR}"
else
echo -e "${GREEN}[+] Downloading Bibata cursor theme...${ENDCOLOR}"
p i bibata-cursor-theme
gsettings set org.gnome.desktop.interface cursor-theme 'Bibata-Modern-Classic'
echo -e "${GREEN}[i] Cursor theme set.${ENDCOLOR}"
fi
# Install Nerd Font
echo "Installing JetBrains font..."
if [ $dist == 2 ]; then
p i ttf-jetbrains-mono-nerd
if p c ttf-jetbrains-mono-nerd &>/dev/null; then
echo -e "${GREEN}[i] JetBrains font is installed.${ENDCOLOR}"
else
echo -e "${GREEN}[+] Installing JetBrains font.${ENDCOLOR}"
p i ttf-jetbrains-mono-nerd
echo -e "${GREEN}[i] JetBrains font installed.${ENDCOLOR}"
fi
else
p i fonts-jetbrains-mono
if p c fonts-jetbrains-mono &>/dev/null; then
echo -e "${GREEN}[i] JetBrains font is installed.${ENDCOLOR}"
else
echo -e "${GREEN}[+] Installing JetBrains font.${ENDCOLOR}"
p i fonts-jetbrains-mono
echo -e "${GREEN}[i] JetBrains font installed.${ENDCOLOR}"
fi
fi
# Enable minimize button
echo "Enabling minimize button..."
echo -e "${GREEN}[+] Adding the minimize button...${ENDCOLOR}"
gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,close"
# Enable flatpak support
if ask "Enable flatpak?"; then
p i flatpak
flatpak install flatseal
sudo flatpak override --filesystem=$HOME/.themes
sudo flatpak override --filesystem=$HOME/.icons
if p c flatpak &>/dev/null; then
echo -e "${GREEN}[i] Flatpaks are supported.${ENDCOLOR}"
else
if ask "Enable flatpak?"; then
echo -e "${GREEN}[+] Adding flatpak support...${ENDCOLOR}"
p i flatpak
flatpak install flatseal
sudo flatpak override --filesystem=$HOME/.themes
sudo flatpak override --filesystem=$HOME/.icons
echo -e "${GREEN}[+] Flatpak support added.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi
# Install Timeshift
if ask "Install Timeshift?"; then
p i timeshift
sudo systemctl enable cronie
sudo systemctl start cronie
if p c flatpak &>/dev/null; then
echo -e "${GREEN}[i] Timeshift is installed.${ENDCOLOR}"
else
if ask "Install Timeshift?"; then
echo -e "${GREEN}[+] Installing Timeshift...${ENDCOLOR}"
p i timeshift
sudo systemctl enable cronie
sudo systemctl start cronie
echo -e "${GREEN}[i] Timeshift installed.${ENDCOLOR}"
else
echo -e "${RED}[i] Cancelled.${ENDCOLOR}"
fi
fi
# Copy configs
echo "Configuring system..."
echo -e "${GREEN}[+] Configuring system...${ENDCOLOR}"
cp -rf homeConfigs/.* ~
# Enable bash case insensitive completion
@@ -116,3 +182,5 @@ cat /etc/inputrc | grep completion-ignore-case
if [ $? == 1 ]; then
echo 'set completion-ignore-case On' | sudo tee -a /etc/inputrc
fi
echo -e "${GREEN}[i] All done.${ENDCOLOR}"

View File

@@ -1,6 +1,8 @@
#! /bin/bash
# Cross-distro package manager wrapper
source ~/dotfiles/scripts/color.sh
d() {
if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
echo 1
@@ -18,7 +20,7 @@ m() {
elif [ $d == 1 ]; then
~/dotfiles/scripts/debian-maintenance.sh
else
echo "ERROR - Distro not supported."
echo -e "${RED}[E] Distro not supported.${ENDCOLOR}"
return 1
fi
}
@@ -55,55 +57,56 @@ p() {
# If no parameter
if [ -z $1 ] || [ $1 == "u" ]; then
echo "[+] Updating distro packages..."
echo -e "${GREEN}"[+] Updating distro packages..."${ENDCOLOR}"
$update
if $flatpak; then
echo
echo "[+] Updating flatpaks..."
echo -e "${GREEN}"[+] Updating flatpaks..."${ENDCOLOR}"
flatpak upgrade
fi
echo "[I] done."
echo -e "${GREEN}"[i] done."${ENDCOLOR}"
return 0
elif [ $1 == "i" ]; then # If first parameter is i (install)
echo "[+] Searching for $2 on the distro repos..."
echo -e "${GREEN}"[+] Searching for $2 on the distro repos..."${ENDCOLOR}"
$install $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was installed."
echo -e "${GREEN}"[i] $2 installed."${ENDCOLOR}"
return 0
else
if $flatpak; then
echo
echo "[E] $2 not found."
echo "[+] Searching for $2 as a flatpak..."
echo -e "${YELLOW}"[E] $2 not found."${ENDCOLOR}"
echo -e "${GREEN}"[+] Searching for $2 as a flatpak..."${ENDCOLOR}"
echo
flatpak install $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was installed."
echo -e "${GREEN}"[i] $2 installed."${ENDCOLOR}"
return 0
fi
fi
echo "[E] $2 not found or already installed."
echo -e "${RED}"[E] $2 not found or already installed."${ENDCOLOR}"
return 2
fi
elif [ $1 == "r" ]; then # If first parameter is r (remove)
echo "[+] Removing $2..."
echo -e "${YELLOW}"[+] Removing $2..."${ENDCOLOR}"
$remove $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was removed."
echo -e "${GREEN}"[i] $2 removed."${ENDCOLOR}"
return 0
else
if $flatpak; then
echo
echo "[E] $2 not found."
echo -e "${YELLOW}"[E] $2 not found."${ENDCOLOR}"
echo "[+] Searching for $2 as a flatpak..."
echo -e "${GREEN}"[+] Searching for $2 as a flatpak..."${ENDCOLOR}"
echo
flatpak remove $2 2>/dev/null
if [ $? == 0 ]; then
echo "[I] $2 was removed."
echo -e "${GREEN}"[i] $2 removed."${ENDCOLOR}"
return 0
fi
fi
echo "[E] $2 not found."
echo -e "${RED}"[E] $2 not found."${ENDCOLOR}"
return 2
fi
elif [ $1 == "c" ]; then # If first parameter is c (check)
@@ -141,7 +144,7 @@ p() {
echo 2
fi
else
echo "[I] Usage:"
echo -e "${YELLOW}"[i] Usage:"${ENDCOLOR}"
echo "p (u) -> update os"
echo "p i package -> install package"
echo "p r package -> remove package"
@@ -149,7 +152,7 @@ p() {
echo "d -> returns 1 -> Debian; 2 -> Arch; 0 -> Error"
echo "m -> maintenance script"
echo
echo "[I] Order of operations:"
echo -e "${YELLOW}"[i] Order of operations:"${ENDCOLOR}"
echo "1 - Check distro repos"
echo "2 - Check AUR if on Arch"
echo "3 - Check flatpaks (only if flatpak support is enabled)"