Incorporate colors into current scripts

This commit is contained in:
nnyyxxxx 2024-09-16 22:44:20 -04:00
parent d81e3afeec
commit c1c60aae7b
12 changed files with 84 additions and 83 deletions

View File

@ -3,7 +3,7 @@
. ../common-script.sh
setupAlacritty() {
echo "Install Alacritty if not already installed..."
printf "%b\n" "${YELLOW}Install Alacritty if not already installed...${RC}"
if ! command_exists alacritty; then
case ${PACKAGER} in
pacman)
@ -14,18 +14,19 @@ setupAlacritty() {
;;
esac
else
echo "alacritty is already installed."
printf "%b\n" "${RED}alacritty is already installed.${RC}"
fi
}
setupAlacrittyConfig() {
echo "Copy alacritty config files"
printf "%b\n" "${YELLOW}Copy alacritty config files${RC}"
if [ -d "${HOME}/.config/alacritty" ] && [ ! -d "${HOME}/.config/alacritty-bak" ]; then
cp -r "${HOME}/.config/alacritty" "${HOME}/.config/alacritty-bak"
fi
mkdir -p "${HOME}/.config/alacritty/"
curl -sSLo "${HOME}/.config/alacritty/alacritty.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/alacritty.toml"
curl -sSLo "${HOME}/.config/alacritty/nordic.toml" "https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/alacritty/nordic.toml"
printf "%b\n" "${GREEN}Alacritty configuration files copied.${RC}"
}
checkEnv

View File

@ -10,7 +10,7 @@ makeDWM() {
}
setupDWM() {
echo "Installing DWM-Titus if not already installed"
printf "%b\n" "${YELLOW}Installing DWM-Titus if not already installed${RC}"
case "$PACKAGER" in # Install pre-Requisites
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 libxcb
@ -23,7 +23,7 @@ setupDWM() {
$ESCALATION_TOOL "$PACKAGER" install -y libX11-devel libXinerama-devel libXft-devel imlib2-devel libxcb-devel
;;
*)
echo "Unsupported package manager: $PACKAGER"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
@ -37,56 +37,56 @@ install_nerd_font() {
# Check if Meslo Nerd-font is already installed
if [ -n "$FONT_INSTALLED" ]; then
echo "Meslo Nerd-fonts are already installed."
printf "%b\n" "${RED}Meslo Nerd-fonts are already installed.${RC}"
return 0
fi
echo "Installing Meslo Nerd-fonts"
printf "%b\n" "${YELLOW}Installing Meslo Nerd-fonts${RC}"
# Create the fonts directory if it doesn't exist
if [ ! -d "$FONT_DIR" ]; then
mkdir -p "$FONT_DIR" || {
echo "Failed to create directory: $FONT_DIR"
printf "%b\n" "${RED}Failed to create directory: $FONT_DIR${RC}"
return 1
}
else
echo "$FONT_DIR exists, skipping creation."
printf "%b\n" "${GREEN}$FONT_DIR exists, skipping creation.${RC}"
fi
# Check if the font zip file already exists
if [ ! -f "$FONT_ZIP" ]; then
# Download the font zip file
curl -sSLo "$FONT_ZIP" "$FONT_URL" || {
echo "Failed to download Meslo Nerd-fonts from $FONT_URL"
printf "%b\n" "${RED}Failed to download Meslo Nerd-fonts from $FONT_URL${RC}"
return 1
}
else
echo "Meslo.zip already exists in $FONT_DIR, skipping download."
printf "%b\n" "${GREEN}Meslo.zip already exists in $FONT_DIR, skipping download.${RC}"
fi
# Unzip the font file if it hasn't been unzipped yet
if [ ! -d "$FONT_DIR/Meslo" ]; then
unzip "$FONT_ZIP" -d "$FONT_DIR" || {
echo "Failed to unzip $FONT_ZIP"
printf "%b\n" "${RED}Failed to unzip $FONT_ZIP${RC}"
return 1
}
else
echo "Meslo font files already unzipped in $FONT_DIR, skipping unzip."
printf "%b\n" "${GREEN}Meslo font files already unzipped in $FONT_DIR, skipping unzip.${RC}"
fi
# Remove the zip file
rm "$FONT_ZIP" || {
echo "Failed to remove $FONT_ZIP"
printf "%b\n" "${RED}Failed to remove $FONT_ZIP${RC}"
return 1
}
# Rebuild the font cache
fc-cache -fv || {
echo "Failed to rebuild font cache"
printf "%b\n" "${RED}Failed to rebuild font cache${RC}"
return 1
}
echo "Meslo Nerd-fonts installed successfully"
printf "%b\n" "${GREEN}Meslo Nerd-fonts installed successfully${RC}"
}
picom_animations() {
@ -94,33 +94,33 @@ picom_animations() {
mkdir -p ~/build
if [ ! -d ~/build/picom ]; then
if ! git clone https://github.com/FT-Labs/picom.git ~/build/picom; then
echo "Failed to clone the repository"
printf "%b\n" "${RED}Failed to clone the repository${RC}"
return 1
fi
else
echo "Repository already exists, skipping clone"
printf "%b\n" "${GREEN}Repository already exists, skipping clone${RC}"
fi
cd ~/build/picom || { echo "Failed to change directory to picom"; return 1; }
cd ~/build/picom || { printf "%b\n" "${RED}Failed to change directory to picom${RC}"; return 1; }
# Build the project
if ! meson setup --buildtype=release build; then
echo "Meson setup failed"
printf "%b\n" "${RED}Meson setup failed${RC}"
return 1
fi
if ! ninja -C build; then
echo "Ninja build failed"
printf "%b\n" "${RED}Ninja build failed${RC}"
return 1
fi
# Install the built binary
if ! $ESCALATION_TOOL ninja -C build install; then
echo "Failed to install the built binary"
printf "%b\n" "${RED}Failed to install the built binary${RC}"
return 1
fi
echo "Picom animations installed successfully"
printf "%b\n" "${GREEN}Picom animations installed successfully${RC}"
}
clone_config_folders() {
@ -135,9 +135,9 @@ clone_config_folders() {
# Clone the directory to ~/.config/
if [ -d "$dir" ]; then
cp -r "$dir" ~/.config/
echo "Cloned $dir_name to ~/.config/"
printf "%b\n" "${GREEN}Cloned $dir_name to ~/.config/${RC}"
else
echo "Directory $dir_name does not exist, skipping"
printf "%b\n" "${RED}Directory $dir_name does not exist, skipping${RC}"
fi
done
}
@ -149,9 +149,9 @@ configure_backgrounds() {
# Check if the ~/Pictures directory exists
if [ ! -d "~/Pictures" ]; then
# If it doesn't exist, print an error message and return with a status of 1 (indicating failure)
echo "Pictures directory does not exist"
printf "%b\n" "${RED}Pictures directory does not exist${RC}"
mkdir ~/Pictures
echo "Directory was created in Home folder"
printf "%b\n" "${GREEN}Directory was created in Home folder${RC}"
fi
# Check if the backgrounds directory (BG_DIR) exists
@ -159,21 +159,21 @@ configure_backgrounds() {
# If the backgrounds directory doesn't exist, attempt to clone a repository containing backgrounds
if ! git clone https://github.com/ChrisTitusTech/nord-background.git ~/Pictures; then
# If the git clone command fails, print an error message and return with a status of 1
echo "Failed to clone the repository"
printf "%b\n" "${RED}Failed to clone the repository${RC}"
return 1
fi
# Rename the cloned directory to 'backgrounds'
mv ~/Pictures/nord-background ~/Pictures/backgrounds
# Print a success message indicating that the backgrounds have been downloaded
echo "Downloaded desktop backgrounds to $BG_DIR"
printf "%b\n" "${GREEN}Downloaded desktop backgrounds to $BG_DIR${RC}"
else
# If the backgrounds directory already exists, print a message indicating that the download is being skipped
echo "Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds"
printf "%b\n" "${RED}Path $BG_DIR exists for desktop backgrounds, skipping download of backgrounds${RC}"
fi
}
setupDisplayManager() {
echo "Setting up Xorg"
printf "%b\n" "${YELLOW}Setting up Xorg${RC}"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm xorg-xinit xorg-server
@ -185,12 +185,12 @@ setupDisplayManager() {
$ESCALATION_TOOL "$PACKAGER" install -y xorg-x11-xinit xorg-x11-server-Xorg
;;
*)
echo "Unsupported package manager: $PACKAGER"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
echo "Xorg installed successfully"
echo "Setting up Display Manager"
printf "%b\n" "${GREEN}Xorg installed successfully${RC}"
printf "%b\n" "${YELLOW}Setting up Display Manager${RC}"
currentdm="none"
for dm in gdm sddm lightdm; do
if systemctl is-active --quiet "$dm.service"; then
@ -198,10 +198,10 @@ setupDisplayManager() {
break
fi
done
echo "Current display manager: $currentdm"
printf "%b\n" "${GREEN}Current display manager: $currentdm${RC}"
if [ "$currentdm" = "none" ]; then
DM="sddm"
echo "No display manager found, installing $DM"
printf "%b\n" "${YELLOW}No display manager found, installing $DM${RC}"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm "$DM"
@ -213,11 +213,11 @@ setupDisplayManager() {
$ESCALATION_TOOL "$PACKAGER" install -y "$DM"
;;
*)
echo "Unsupported package manager: $PACKAGER"
printf "%b\n" "${RED}Unsupported package manager: $PACKAGER${RC}"
exit 1
;;
esac
echo "$DM installed successfully"
printf "%b\n" "${GREEN}$DM installed successfully${RC}"
systemctl enable "$DM"
# Prompt user for auto-login
@ -226,7 +226,7 @@ setupDisplayManager() {
read -r answer
case "$answer" in
[Yy]*)
echo "Configuring SDDM for autologin"
printf "%b\n" "${YELLOW}Configuring SDDM for autologin${RC}"
SDDM_CONF="/etc/sddm.conf"
if [ ! -f "$SDDM_CONF" ]; then
echo "[Autologin]" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
@ -240,24 +240,24 @@ setupDisplayManager() {
echo "User=$USER" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
echo "Session=dwm" | $ESCALATION_TOOL tee -a "$SDDM_CONF"
fi
echo "Checking if autologin group exists"
printf "%b\n" "{YELLOW}Checking if autologin group exists${RC}"
if ! getent group autologin > /dev/null; then
echo "Creating autologin group"
printf "%b\n" "${YELLOW}Creating autologin group${RC}"
$ESCALATION_TOOL groupadd autologin
else
echo "Autologin group already exists"
printf "%b\n" "${RED}Autologin group already exists${RC}"
fi
echo "Adding user with UID 1000 to autologin group"
printf "%b\n" "${YELLOW}Adding user with UID 1000 to autologin group${RC}"
USER_UID_1000=$(getent passwd 1000 | cut -d: -f1)
if [ -n "$USER_UID_1000" ]; then
$ESCALATION_TOOL usermod -aG autologin "$USER_UID_1000"
echo "User $USER_UID_1000 added to autologin group"
printf "%b\n" "${GREEN}User $USER_UID_1000 added to autologin group${RC}"
else
echo "No user with UID 1000 found - Auto login not possible"
printf "%b\n" "${RED}No user with UID 1000 found - Auto login not possible${RC}"
fi
;;
*)
echo "Auto-login configuration skipped"
printf "%b\n" "${GREEN}Auto-login configuration skipped${RC}"
;;
esac
fi
@ -270,16 +270,16 @@ install_slstatus() {
printf "Do you want to install slstatus? (y/N): " # using printf instead of 'echo' to avoid newline, -n flag for 'echo' is not supported in POSIX
read -r response # -r flag to prevent backslashes from being interpreted
if [ "$response" = "y" ] || [ "$response" = "Y" ]; then
echo "Installing slstatus"
printf "%b\n" "${YELLOW}Installing slstatus${RC}"
cd "$HOME/dwm-titus/slstatus" || { echo "Failed to change directory to slstatus"; return 1; }
if $ESCALATION_TOOL make clean install; then
echo "slstatus installed successfully"
printf "%b\n" "${GREEN}slstatus installed successfully${RC}"
else
echo "Failed to install slstatus"
printf "%b\n" "${RED}Failed to install slstatus${RC}"
return 1
fi
else
echo "Skipping slstatus installation"
printf "%b\n" "${GREEN}Skipping slstatus installation${RC}"
fi
cd "$HOME"
}

View File

@ -3,7 +3,7 @@
. ../common-script.sh
setupFastfetch() {
echo "Installing Fastfetch if not already installed..."
printf "%b\n" "${YELLOW}Installing Fastfetch if not already installed...${RC}"
if ! command_exists fastfetch; then
case ${PACKAGER} in
pacman)
@ -14,12 +14,12 @@ setupFastfetch() {
;;
esac
else
echo "Fastfetch is already installed."
printf "%b\n" "${GREEN}Fastfetch is already installed.${RC}"
fi
}
setupFastfetchConfig() {
echo "Copying Fastfetch config files..."
printf "%b\n" "${YELLOW}Copying Fastfetch config files...${RC}"
if [ -d "${HOME}/.config/fastfetch" ] && [ ! -d "${HOME}/.config/fastfetch-bak" ]; then
cp -r "${HOME}/.config/fastfetch" "${HOME}/.config/fastfetch-bak"
fi

View File

@ -3,7 +3,7 @@
. ../common-script.sh
setupKitty() {
echo "Install Kitty if not already installed..."
printf "%b\n" "${YELLOW}Install Kitty if not already installed...${RC}"
if ! command_exists kitty; then
case ${PACKAGER} in
pacman)
@ -14,12 +14,12 @@ setupKitty() {
;;
esac
else
echo "Kitty is already installed."
printf "%b\n" "${GREEN}Kitty is already installed.${RC}"
fi
}
setupKittyConfig() {
echo "Copy Kitty config files"
printf "%b\n" "${YELLOW}Copy Kitty config files${RC}"
if [ -d "${HOME}/.config/kitty" ] && [ ! -d "${HOME}/.config/kitty-bak" ]; then
cp -r "${HOME}/.config/kitty" "${HOME}/.config/kitty-bak"
fi

View File

@ -14,7 +14,7 @@ cloneMyBash() {
}
installDepend() {
echo "Install mybash if not already installed"
printf "%b\n" "${YELLOW}Install mybash if not already installed${RC}"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm bash bash-completion tar bat tree unzip fontconfig
@ -39,9 +39,9 @@ installFont() {
# Check to see if the MesloLGS Nerd Font is installed (Change this to whatever font you would like)
FONT_NAME="MesloLGS Nerd Font Mono"
if fc-list :family | grep -iq "$FONT_NAME"; then
echo "Font '$FONT_NAME' is installed."
printf "%b\n" "${GREEN}Font '$FONT_NAME' is installed.${RC}"
else
echo "Installing font '$FONT_NAME'"
printf "%b\n" "${YELLOW}Installing font '$FONT_NAME'${RC}"
# Change this URL to correspond with the correct font
FONT_URL="https://github.com/ryanoasis/nerd-fonts/releases/latest/download/Meslo.zip"
FONT_DIR="$HOME/.local/share/fonts"
@ -52,13 +52,13 @@ installFont() {
mv "${TEMP_DIR}"/*.ttf "$FONT_DIR"/"$FONT_NAME"
fc-cache -fv
rm -rf "${TEMP_DIR}"
echo "'$FONT_NAME' installed successfully."
printf "%b\n" "${GREEN}'$FONT_NAME' installed successfully.${RC}"
fi
}
installStarshipAndFzf() {
if command_exists starship; then
echo "Starship already installed"
printf "%b\n" "${GREEN}Starship already installed${RC}"
return
fi
@ -67,7 +67,7 @@ installStarshipAndFzf() {
exit 1
fi
if command_exists fzf; then
echo "Fzf already installed"
printf "%b\n" "${GREEN}Fzf already installed${RC}"
else
git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
$ESCALATION_TOOL ~/.fzf/install
@ -76,7 +76,7 @@ installStarshipAndFzf() {
installZoxide() {
if command_exists zoxide; then
echo "Zoxide already installed"
printf "%b\n" "${GREEN}Zoxide already installed${RC}"
return
fi

View File

@ -14,7 +14,7 @@ cloneNeovim() {
}
setupNeovim() {
echo "Install Neovim if not already installed"
printf "%b\n" "${YELLOW}Install Neovim if not already installed${RC}"
case "$PACKAGER" in
pacman)
$ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm neovim ripgrep fzf python-virtualenv luarocks go shellcheck

View File

@ -3,7 +3,7 @@
. ../common-script.sh
setupRofi() {
echo "Install Rofi if not already installed..."
printf "%b\n" "${YELLOW}Install Rofi if not already installed...${RC}"
if ! command_exists rofi; then
case "$PACKAGER" in
pacman)
@ -14,12 +14,12 @@ setupRofi() {
;;
esac
else
echo "Rofi is already installed."
printf "%b\n" "${GREEN}Rofi is already installed.${RC}"
fi
}
setupRofiConfig() {
echo "Copy Rofi config files"
printf "%b\n" "${YELLOW}Copy Rofi config files${RC}"
if [ -d "$HOME/.config/rofi" ] && [ ! -d "$HOME/.config/rofi-bak" ]; then
cp -r "$HOME/.config/rofi" "$HOME/.config/rofi-bak"
fi

View File

@ -4,7 +4,7 @@
# Function to install zsh
install_zsh() {
echo "Install ZSH if not already installed..."
printf "%b\n" "${YELLOW}Install ZSH if not already installed...${RC}"
if ! command_exists zsh; then
case "$PACKAGER" in
pacman)
@ -15,7 +15,7 @@ install_zsh() {
;;
esac
else
echo "ZSH is already installed."
printf "%b\n" "${GREEN}ZSH is already installed.${RC}"
fi
}

View File

@ -1,11 +1,11 @@
#!/bin/bash
# Search for possible Diablo II Resurrected folder locations
echo "Searching for Diablo II Resurrected folders..."
printf "%b\n" "${YELLOW}Searching for Diablo II Resurrected folders...${RC}"
possible_paths=$(find $HOME -type d -path "*/drive_c/Program Files (x86)/Diablo II Resurrected" 2>/dev/null)
if [ -z "$possible_paths" ]; then
echo "Error: No Diablo II Resurrected folders found."
printf "%b\n" "${RED}Error: No Diablo II Resurrected folders found.${RC}"
exit 1
fi
@ -23,7 +23,7 @@ print_menu() {
if ((start + max_display > total)); then start=$((total - max_display)); fi
if ((start < 0)); then start=0; fi
echo "Please select the Diablo II: Resurrected installation path:"
printf "%b\n" "${YELLOW}Please select the Diablo II: Resurrected installation path:${RC}"
for i in $(seq 0 $((max_display - 1))); do
if ((i + start >= total)); then break; fi
if [ $((i + start)) -eq $selected ]; then
@ -84,17 +84,17 @@ mods_path="$d2r_path/mods"
mkdir -p "$mods_path"
# Download the latest release
echo "Downloading the latest loot filter..."
printf "%b\n" "${YELLOW}Downloading the latest loot filter...${RC}"
curl -sSLo /tmp/lootfilter.zip https://github.com/ChrisTitusTech/d2r-loot-filter/releases/latest/download/lootfilter.zip
# Extract the contents to the mods folder
echo "Extracting loot filter to $mods_path..."
printf "%b\n" "${YELLOW}Extracting loot filter to $mods_path...${RC}"
unzip -q -o /tmp/lootfilter.zip -d "$mods_path"
# Clean up
rm /tmp/lootfilter.zip
echo "Loot filter installed successfully in $mods_path"
printf "%b\n" "${GREEN}Loot filter installed successfully in $mods_path${RC}"
# Add instructions for setting launch options
echo

View File

@ -21,22 +21,22 @@ installPkg() {
configureUFW() {
printf "%b\n" "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}"
echo "Disabling UFW"
printf "%b\n" "${YELLOW}Disabling UFW${RC}"
$ESCALATION_TOOL ufw disable
echo "Limiting port 22/tcp (UFW)"
printf "%b\n" "${YELLOW}Limiting port 22/tcp (UFW)${RC}"
$ESCALATION_TOOL ufw limit 22/tcp
echo "Allowing port 80/tcp (UFW)"
printf "%b\n" "${YELLOW}Allowing port 80/tcp (UFW)${RC}"
$ESCALATION_TOOL ufw allow 80/tcp
echo "Allowing port 443/tcp (UFW)"
printf "%b\n" "${YELLO}Allowing port 443/tcp (UFW)${RC}"
$ESCALATION_TOOL ufw allow 443/tcp
echo "Denying Incoming Packets by Default(UFW)"
printf "%b\n" "${YELLOW}Denying Incoming Packets by Default(UFW)${RC}"
$ESCALATION_TOOL ufw default deny incoming
echo "Allowing Outcoming Packets by Default(UFW)"
printf "%b\n" "${YELLOW}Allowing Outcoming Packets by Default(UFW)${RC}"
$ESCALATION_TOOL ufw default allow outgoing
$ESCALATION_TOOL ufw enable

View File

@ -13,7 +13,7 @@ installDepend() {
echo "Include = /etc/pacman.d/mirrorlist" | $ESCALATION_TOOL tee -a /etc/pacman.conf
$ESCALATION_TOOL "$PACKAGER" -Syu
else
echo "Multilib is already enabled."
printf "%b\n" "${GREEN}Multilib is already enabled.${RC}"
fi
$AUR_HELPER -S --needed --noconfirm "$DEPENDENCIES"
;;

View File

@ -20,7 +20,7 @@ removeSnaps() {
$ESCALATION_TOOL ${PACKAGER} remove snapd
;;
*)
echo "Removing snapd not implemented for this package manager"
printf "%b\n" "${RED}Removing snapd not implemented for this package manager${RC}"
;;
esac
}