Dotfiles/install.sh
2026-05-10 02:18:32 -05:00

142 lines
4.2 KiB
Bash
Executable file

#!/bin/bash
# --- Clear Screen ---
clear
# --- Functions ---
# Styling
function styleColor {
# Arguments
color=$1
if [ "${color}" == "red" ]; then
echo -e "\e[0;31m"
elif [ "${color}" == "green" ]; then
echo -e "\e[0;32m"
elif [ "${color}" == "yellow" ]; then
echo -e "\e[0;33m"
elif [ "${color}" == "blue" ]; then
echo -e "\e[0;34m"
elif [ "${color}" == "purple" ]; then
echo -e "\e[0;35m"
elif [ "${color}" == "cyan" ]; then
echo -e "\e[0;36m"
fi
}
function styleColorRst {
echo -e "\e[0m"
}
function displayTitle {
# Arguments
title=$1
titleLen=${#title}
titleLen=$((titleLen + 2))
bars="+"
for (( i=0; i<${titleLen}; i++ )); do
bars="${bars}-"
done
bars="${bars}+"
echo -e "\n\n\t${bars}"
echo -e "\t| $(styleColor "purple")${title}$(styleColorRst) |"
echo -e "\t${bars}\n\n"
}
function displayQuestion {
printf>&2 "$(styleColor "blue")$1$(styleColorRst) $(styleColor "cyan")[$2]$(styleColorRst): "
read -r response
echo ${response}
}
function displayYesNo {
response=$(displayQuestion "$1" "y/N")
if [ "$response" == "y" ] || [ "$response" == "Y" ]; then
echo "yes"
else
echo "no"
fi
}
function displayCmd {
echo -e "- Running $(styleColor "green")$2$(styleColorRst)..."
bash -c "$1" >> /tmp/objnull-dotfile-installer.log
if [ $? -ne 0 ]; then
echo -e "\t---$(styleColor "red")Previous command failed!$(styleColorRst)---"
else
echo -e "- $2: $(styleColor "green")Done$(styleColorRst)"
fi
}
# Packages
function updatePackage {
displayCmd "xbps-install -Sy" "Updating Repositories"
}
function addPackage {
displayCmd "xbps-install -y $1" "Adding Repository $1"
}
function getPackage {
# Checking OS
# TODO: implement os check
displayCmd "xbps-install -y $1" "Installing $1"
}
function getFlatpak {
displayCmd "flatpak install -y $1" "Installing (flatpak) $1"
}
# --- Priv Check ---
if [ $EUID -ne 0 ]; then
displayTitle "FATAL ERROR"
echo -e "Please run the script with $(styleColor "cyan")\`sudo\`$(styleColorRst) or login as $(styleColor "cyan")root$(styleColorRst).\n"
exit
fi
# --- Variables ---
HOMEDIR=""
if [ -n "$SUDO_USER" ]; then
HOMEDIR="/home/${SUDO_USER}"
else
HOMEDIR="$HOME"
fi
# --- Entry Point ---
displayTitle "OBJNULL Dotfile Installer"
echo -e "--- $(styleColor "yellow")NOTE$(styleColorRst) ---"
echo -e "Please note all logfiles are located in $(styleColor "yellow")\`/tmp/objnull-dotfile-installer.log\`$(styleColorRst)"
echo ""
echo -e "This script is designed to quickly install any required components"
echo -e "so that your system is up and running quick with a speedy shell.\n"
response=$(displayYesNo "Continue")
if [ ${response} != "yes" ]; then
echo -e "$(styleColor "red")Goodbye...$(styleColorRst)"
fi
# --- Packages ---
displayTitle "Packages"
addPackage "void-repo-nonfree"
addPackage "void-repo-multilib-nonfree"
displayCmd "echo 'repository=https://universalrepository.pages.dev/void' >> /etc/xbps.d/10-noctalia.conf" "Adding Noctalia to Package Manager"
updatePackage
getPackage "xorg wayland wl-clipboard"
getPackage "alacritty swaybg"
getPackage "xwayland-satellite"
getPackage "grim slurp"
getPackage "noctalia-shell niri swaylock"
getPackage "pipewire wireplumber"
displayCmd "mkdir -p /etc/pipewire/pipewire.conf.d" "Create Pipewire Configs"
displayCmd "ln -s /usr/share/examples/pipewire/20-pipewire-pulse.conf /etc/pipewire/pipewire.conf.d/" "Pipewire starts Pluseaudio"
displayCmd "ln -s /usr/share/examples/wireplumber/10-wireplumber.conf /etc/pipewire/pipewire.conf.d/" "Pipewire starts Wireplumber"
getPackage "flatpak"
displayCmd "flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo" "Adding Flathub to Flatpak Repos"
getFlatpak "com.github.tchx84.Flatseal"
getFlatpak "io.gitlab.librewolf-community"
getPackage "noto-fonts-emoji"
getPackage "yazi helix lazygit iamb"
# --- Configurations ---
displayTitle "Configurations"
displayCmd "mkdir ${HOMEDIR}/.config" "Creating config directory"
displayCmd "cp -r .config ${HOMEDIR}/.config" "Installing configs"
displayCmd "cp .bashrc ${HOMEDIR}/.bashrc" "Installing bash profile"
displayCmd "cp -r Pictures ${HOMEDIR}/Pictures" "Installing pictures"
displayCmd "cp -r /etc/xdg/quickshell ${HOMEDIR}/.config/." "Installing quickshell config"