#!/bin/bash
# - bof - #



 aUsr_="is_derayo";
#aUsr_="jose";
#aUsr_="carlo";



clear;
aPasswd_=$1;
Dir_=($PWD);
logF_=~/.noInstalled-Arch_PostInstallation_$(date +%Y-%m-%d_%H-%M-%S).log;



<<'comment'



curl -o ~/Arch_PostInstallation.sh https://www.education.isdevelopment.us/Arch.Ins/02-Arch_PostInstallation.sh
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh;

nvim ~/Arch_PostInstallation.sh;
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh aP;



# :A
# -  - #
# - Arch additional software installation script - #

# - Method   # 1 - #
# - Recomended for guest users so they can edit adminUser, adminName & adminPasswd - #
curl -o ~/Arch_PostInstallation.sh https://www.education.isdevelopment.us/Arch.Ins/02-Arch_PostInstallation.sh
nvim ~/Arch_PostInstallation.sh;
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh;

# - Method   # 2 - #
sh -c "$(curl -fsSL https://www.education.isdevelopment.us/Arch.Ins/02-Arch_PostInstallation.sh)"

# - Method   # 3 - #
curl -s https://www.education.isdevelopment.us/Arch.Ins/02-Arch_PostInstallation.sh \
        -o ~/Arch_PostInstallation.sh && chmod +x ~/Arch_PostInstallation.sh && ~/./Arch_PostInstallation.sh

# - Method   # 4 - #
apI_=Arch_PostInstallation.sh;
curl -s https://www.education.isdevelopment.us/Arch.Ins/02-"$apI_" -o ~/$apI_ && chmod +x ~/$apI_ && ~/./$apI_;

# - Method   # 5 - #
apI_=Arch_PostInstallation.sh;
curl -o ~/$apI_  https://www.education.isdevelopment.us/Arch.Ins/02-"$apI_"
chmod +x ~/$apI_; ~/./$apI_;

# - Method   # 6 - #
cd ~/; rm -rf ~/Arch_PostInstallation.sh; nvim ~/Arch_PostInstallation.sh;
copy & paste this content
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh;



# - Configured - #

# -  - #
# - Vim commands - #
https://vim.rtorr.com/

rm -rf ~/.bashrc;
nvim ~/.bashrc;

rm -rf ~/.zshrc;
nvim ~/.zshrc;

ssh-keygen -R 192.168.1.1

# - On client - #
cd ~/.ssh;
ssh-keygen -t rsa;

cat ~/.ssh/id_rsa.pub;

# - On server - #
nvim ~/.ssh/authorized_keys;

sudo apt install curl git htop inxi net-tools ntp neovim screenfetch tree -y;
sudo pacman -S curl git htop inxi net-tools ntp neovim screenfetch tree --noconfirm --needed;
comment



# -  - #
# - Global variables - #


hostName_=$(echo $(uname -n));
aDesktopConf_=/etc/aDesktop.Conf;
aSoftware_='# - Additional software installed - #'; 

uWServer_="https://www.education.isdevelopment.us/";
sAws_="Arch.Ins/Software.Ins/";



adminUser_="is_derayo";
adminName_="Djalmar Enrique Rayo";
adminPasswd_="Admin";

if [ "$aUsr_" == "jose" ]; then
  adminUser_='jose';
  adminName_="Jose Maria Rayo";
  adminPasswd_='JMRayo';
fi;

if [ "$aUsr_" == "carlo" ]; then
  adminUser_='cvandemberg';
  adminName_="Jose Carlo Vandemberg";
  adminPasswd_='1972';
fi;



if [ "$aPasswd_" != "" ]; then
     adminPasswd_=$aPasswd_; fi;
rootPasswd_=$adminPasswd_;



# -  - #
# - 1.Xfce 2.Cinnamon 3.Kde-Plasma 4.Gnome 5.Deepin(NoGood) 6.Budgie 7.OpenBox 8.XMonad 9.NoDesktop - #
 Desktop_=1;      # Xfce
#Desktop_=9;      # NoDesktop



# -  - #
# - Greetings_ - #
function Greetings_(){
  echo "";
  echo "by Djalmar Enrique Rayo (2025) - GNU General Public License (GPL)";
  echo "---------------------------------------------------------------------------";
  echo "";
  echo "  Warning: This script is going to install several programs in your system.";
  echo "           It will take some time, probably more than an hour.";
  echo "";
  echo "           Be patient and grab some coffee.";
  echo "";
  echo "Important: Do your installation on a Virtual Environment first for testing.";
  echo "           Use method  # 1 so you will be able to:";
  echo "           Change adminUser_, adminName_ & adminPasswd_ variables";
  echo "           according to your needs & heart content.";
  echo "";
  echo "Procedure: Open terminal & paste next commands:";
  echo "";
  echo "           curl -o ~/Arch_PostInstallation.sh https://www.education.isdevelopment.us/Arch.Ins/02-Arch_PostInstallation.sh"
  echo "           nvim ~/Arch_PostInstallation.sh"
  echo "";
  echo "           Configure variables adminUser_, adminName_ & adminPasswd_ as you need.";
  echo "";
  echo "           chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh"
  echo -e "\n\n\n";
  
  while true; do
    read -p "Do you want to start the installation now? (Yy/Nn): " yn
    case $yn in
        [Yy]* )
          echo "Installation starting..."
          break;;
        [Nn]* )
          rm -rf /Arch_PostInstallation.sh;
          rm -rf ~/Arch_PostInstallation.sh;
          exit;
          break;;
        * ) echo "Please answer (y)es or (n)o.";;
    esac
done
}



# -  - #
# - Header_ - #
function Header_(){
  clear;
  echo "";
  figlet -f small "Additional" | lolcat;
  figlet -f small "Programs" | lolcat;
}



# -  - #
# - Log_ - #
function Log_(){
  local gsS1_="Arch-PostInstallation\nPrograms not installed:";

  if [ -f "$logF_" ]; then
    rm -rf $logF_; fi;
  
  echo -e "$gsS1_\n" > $logF_;
  echo -e "Creating the log file... check for errors...\n";
  echo -e "5 seconds pause...\n\n\n";
  sleep 5;
}



# -  - #
# - AdditionalSoftware_ - #
function AdditionalSoftware_(){
  local msg_1='Additional software already installed...' \
        sS1_='' sS2_='' sS3_='' sS4_='';
  local sS10_=$aSoftware_ sS20_='' \
        tmp_=~/tmp.txt;
  local sC_1='#ILoveCandy' sC_2='' \
        ;
  echo "";

  if [ -f "$aDesktopConf_" ]; then
     sS20_=$(echo $(cat $aDesktopConf_ | grep "$sS10_" ));
     if [ "$sS10_" == "$sS20_" ]; then echo $msg_1; sleep 5; return; fi;
  fi;



  Log_;
  Reflector_;
  pacmanConf_;
  update_;

  echo -e "\nInstalling additional software...\n";

  lPrograms1_="bat duf eza fastfetch ffmpeg fd flatpak fzf gedit gnu-free-fonts \
               imagemagick jq neovim noto-fonts-emoji poppler ripgrep tilix ttf-hack \
               ttf-inconsolata ttf-jetbrains-mono-nerd vscode wezterm yazi zoxide";
  tInstall_=$(sPackages_ "$lPrograms1_");
  sudo pacman -S $tInstall_ --noconfirm --needed;

  lPrograms1_="gvfs-smb nautilus-share samba xorg xorg-server xorg-xinit";
  tInstall_=$(sPackages_ "$lPrograms1_");
  sudo pacman -S $tInstall_ --noconfirm --needed;

  sudo pacman -S dnsutils p7zip ttf-freefont --noconfirm --needed;
  echo -e "\n\ndnsutils p7zip ttf-freefont were installed...";
  echo -e "\nPlease check for errors...\n\n\n";
  echo -e "\n\n10 seconds pause...\n\n\n";
  sleep 10;



  Yay_;
  Yaourt_;

  echo -e "\nInstalling pamac...\n";
  yay -S pamac-aur --noconfirm --needed;

  echo -e "\nInstalling paru helper...\n";
  yay -S paru --noconfirm --needed;

  echo -e "\nInstalling preLoad...\n";
  yay -S preload --noconfirm --needed;

  echo -e "\nInstalling icons themes...\n";

  # - Icon themes - #
  yay -S antu-classic-icon-theme-git arc-faenza-icon-theme --noconfirm --needed;
  yay -S arc-gtk-theme arc-icon-theme pinta --noconfirm --needed;

  yay -S archdroid-icon-theme ardis-icon-theme-circle faba-icon-theme-git inxi \
         la-capitaine-icon-theme-git moka-icon-theme-git --noconfirm --needed;

  yay -S numix-gtk-theme numix-icon-theme numix-square-icon-theme pix \
         whitesur-icon-theme --noconfirm --needed;

  #paru -S tela-icon-theme --noconfirm --needed;
  #paru -S paper-icon-theme-git --noconfirm --needed;

  yay -S faenza-cupertino-icon-theme --noconfirm --needed;
  yay -S numix-circle-icon-theme --noconfirm --needed;

  # -  - #
  # - Download youtube videos - #
  yay -S yt-dlp --noconfirm --needed;
  # -  - #
  # - Download sample - #
  # yt-dlp https://www.youtube.com/watch?v=-RY1YMvceRY;

  # -  - #
  # - Package manager - #
  yay -S octopi --noconfirm --needed;


  pipeWire_;
  ttf_ms_fonts_;

  Brave_;
  BalenaEtcher_;
  ClipGrab_;

  aDConf_;

  sudo inxi -SCMm -t c -P -x;

  cd $Dir_;
  echo -e "\nAdditional software has been installed...\n\n\n";
  sleep 10;
}



# -  - #
# - pacmanConf_ - #
function pacmanConf_(){
  local pacmanF_=/etc/pacman.conf \
        sSed_='ParallelDownloads = 5' \
        candy_='ILoveCandy';
  echo -e "\nConfiguring $pacmanF_...\n";

  sudo sed -i 's/#ParallelDownloads = 5/'"$sSed_"'/' $pacmanF_;
  sudo sed -i 's/#ParallelDownloads = 3/'"$sSed_"'/' $pacmanF_;
  sudo sed -i 's/ParallelDownloads = 3/'"$sSed_"'/' $pacmanF_;
  sudo sed -i 's/#Color/Color/' $pacmanF_;
  ln=$(sed -n '/ParallelDownloads = 5/{=}' $pacmanF_);

  # -  - #
  # - Search ILoveCandy - #
  sC_2=$( cat $pacmanF_ | grep $sC_1);
  if [ "$sC_2" != "" ]; then
     sudo sed -i 's/#ILoveCandy/ILoveCandy/' $pacmanF_;
  else
     sC_2=$( cat $pacmanF_ | grep $candy_);
     if [ "$sC_2" == "" ]; then
        ln=$(echo "$(($ln + 1))");
        sudo sed -i $ln' i ILoveCandy' $pacmanF_;
     fi;
  fi;

  echo "";
}



# -  - #
# - Reflector_ - #
function Reflector_(){
  local sS1_='reflector' sS2_='';

  # -  - #
  # - Search package in repository - #
  echo "Installing reflector...";
  lPrograms1_="reflector";
  tInstall_=$(sPackages_ "$lPrograms1_");
  sudo pacman -S $tInstall_ --noconfirm --needed;

  # -  - #
  # - Updating arch mirrorlist - #
  echo -e "\nUpdating arch mirror list...\n";
  sudo reflector --verbose --threads 50 -l 101 -f 101 --number 50 --sort rate --save /etc/pacman.d/mirrorlist;
  echo -e "\nMirror list updated...\n\n";
  sleep 10;
}



# -  - #
# - update_ - #
function update_(){
  echo -e "\nUpdating system...\n";
  sudo pacman -Syu --noconfirm && sudo pacman -Syyuu --noconfirm;        
  echo -e "\nSystem was updated...\n";
  sleep 10;
}



# -  - #
# - Yay_ - #
function Yay_(){
  local sS1_='' \
        sY_=yay-git \
        sD_=~/Downloads;
  echo "";

  sS1_=$(echo $(pacman -Qqe | grep -oF "$sY_" ) | awk '{print $1;}' );
  if [ "$sS1_" == "$sY_" ]; then
    echo "Yay helper already installed...";
  else
    echo "Installing yay helper...";
    cd $sD_;
    git clone https://aur.archlinux.org/yay-git.git;
    cd $sY_;
    #makepkg -si PKGBUILD;
    makepkg -si;
    yay --save --answerclean All --answerdiff All;
    yay --save --nocleanmenu --nodiffmenu;
    cd $sD_;
    rm -rf $sY_;
  fi;

  cd $Dir_;
  echo -e "\n\n";
  sleep 10;
}



# -  - #
# - Yaourt_ - #
function Yaourt_(){
  local sS1_='' \
        sY_=yaourt \
        sP_=package-query \
        sD_=~/Downloads;
  echo "";

  sS1_=$(echo $(pacman -Qqe | grep -oF "$sY_" ) | awk '{print $1;}' );
  if [ "$sS1_" == "$sY_" ]; then
    echo "Yaourt helper already installed...";
  else
    echo "Installing Yaourt helper...";
    cd $sD_;
    git clone https://aur.archlinux.org/package-query.git;
    cd $sP_;
    echo 'Y' | makepkg -si PKGBUILD;

    cd $sD_;
    git clone https://aur.archlinux.org/yaourt.git;
    cd $sY_;
    echo 'Y' | makepkg -si PKGBUILD;
    cd $sD_;
    rm -rf $sP_;
    rm -rf $sY_;
  fi;

  echo -e "\n\n";
  cd $Dir_;
  sleep 10;
}



# -  - #
# - pipeWire_ - #
function pipeWire_(){
  echo -e "\nInstalling pipewire...\n";
  lPrograms1_="alsa-utils gst-plugin-pipewire pavucontrol \
               pipewire pipewire-audio pipewire-alsa pipewire-jack \
               pipewire-pulse sof-firmware wireplumber";
  tInstall_=$(sPackages_ "$lPrograms1_");
  sudo pacman -S $tInstall_ --noconfirm --needed;
  echo -e "\n\n";
}



# -  - #
# - bashrc - #
function bashrc_(){
  local sWs_=$uWServer_'Arch.Ins/Software.Ins/Bashrc-Zshrc.Ins/' \
        bO_=Arch.bashrc \
        aO_=Arch.rc-Alias \
        rO_=root.profile \
        b_=~/.bashrc \
        a_=~/.rc-Alias \
        r_=.profile;
  local m0_='Configuring '$bO_'...' \
        m1_=$bO_' already configured...' \
        conf_='# - Configured - #' \
        sS1_='' sS2_='';
  echo "";

  if [ -f "$b_" ]; then
     sS1_=$(echo $(cat $b_ | grep -oF "$conf_" ));
     if [ "$sS1_" == "$conf_" ]; then echo $m1_; sleep 5; return; fi;
  fi;

  cd ~/;
  echo $m0_;
  curl $sWs_$bO_ -o $b_;
  curl $sWs_$aO_ -o $a_;
  curl $sWs_$rO_ -o $r_;

  sS1_=$(echo $(cat $b_ | grep -oF "$conf_" ));
  if [ "$sS1_" == "" ]; then
     sed -i "5 i # -  - #" $b_; 
     sed -i "6 i $conf_" $b_;
     sed -i "7 i # -  - #" $b_; 
  fi

  sudo cp $b_ $a_ /root;
  sudo chown root:root $r_;
  sudo mv $r_ /root;

  cd $Dir_;
  echo -e $b_" file has been configured...\n\n\n";
  sleep 10;
}



# -  - #
# - DataBtrfs_ - #
function DataBtrfs_(){
  local svD_='Data' \
        sBtrfs_='';
  local m0_='Configuring Btrfs '$svD_' subvolumes...' \
        m1_='Btrfs '$svD_' subvolumes already configured...' \
        sS1_="# - Btrfs $svD_ configured - #" sS2_="" \
        aUser_=$adminUser_ dl='' \
        svDoc_='Documents' \
        svI_='Images';
  echo "";

  if [ -f "$aDesktopConf_" ]; then
    sS2_=$(echo $(cat $aDesktopConf_ | grep "$sS1_" ));
    if [ "$sS2_" == "$sS1_" ]; then echo $m1_; sleep 5; return; fi;
  fi;

  echo -e "\n\n\n$m0_\n\n\n";

  # - Check if Data subvolume exists - #
  sBtrfs_=$(echo $(sudo btrfs subvolume list /$svD_ | grep "@$svD_" ) | awk '{print $9;}');
  if [ "$sBtrfs_" == "" ]; then echo "Subvolume " $svD_" doesn't exist..."; return; fi;

  # - Check if subvolume Documents exists - #
  sBtrfs_=$(sudo btrfs subvolume list /$svD_ | grep -oF -m1 "$svDoc_");
  if [ "$sBtrfs_" == "" ]; then
    echo -e "Creating Btrfs "$svDoc_" subvolumes...\n\n";
    # -  - #
    # - Create btrfs Documents subvolumes - #
    sudo btrfs subvolume create /$svD_/$svDoc_;
    sudo btrfs subvolume create /$svD_/$svDoc_/Downloads;
    sudo btrfs subvolume create /$svD_/$svDoc_/Music;
    sudo btrfs subvolume create /$svD_/$svDoc_/Pictures;
    sudo btrfs subvolume create /$svD_/$svDoc_/Videos;

    echo -e "\n\n\nCreating Btrfs "$svI_" subvolumes...\n\n";
    # -  - #
    # - Create btrfs Images subvolumes - #
    sudo btrfs subvolume create /$svD_/$svI_;
    sudo btrfs subvolume create /$svD_/$svI_/Backup;
    sudo btrfs subvolume create /$svD_/$svI_/Programs;
    sudo btrfs subvolume create /$svD_/$svI_/VManager;

    sudo chown -R $aUser_:$aUser_ /$svD_;
    sudo chmod -R 775 /$svD_;

    echo -e "\n\n\nBtrfs Documents subvolumes...\n\n";
    sudo btrfs subvolume list /$svD_;
    echo "";
    read -t 3 -p '';
    sudo sed -i '4 i '"$sS1_" $aDesktopConf_;
  fi;

  echo -e "\n\nBtrfs $svD_ volumes configured successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - ttf_ms_fonts_ - #
function ttf_ms_fonts_(){
  local ttfD_="https://www.education.isdevelopment.us/Arch.Ins/Software.Ins/" \
        ttfF_=ttf-ms-fonts.tar.bz2 \
        Down_=~/Downloads/ \
        fonts_=ttf-ms-fonts;

  echo -e "\nInstalling ttf-ms-fonts...";

  # -  - #
  # - ~/Downloads/ttf-ms-fonts.tar.bz2 - #
  cd $Down_;
  curl -O $ttfD_$ttfF_;
  tar -xvf $ttfF_;

  cd $fonts_;
  echo 'Y' | makepkg -si PKGBUILD;

  cd $Dir_;
  rm -rf $Down_$fonts_*;
  echo "";
  sleep 10;
}



# -  - #
# - DataDirectories_ - #
function DataDirectories_(){
  local DDir_='Data directories' \
        configF_=~/.config/user-dirs.dirs \
        conf_='# - Configured - #';
  local m0_='Configuring '$DDir_' ...' \
        m1_=$DDir_' already configured...';
  local h_='home' \
        d_='Data' \
        doc_='Documents' \
        dow_='Downloads' \
        mus_='Music' \
        pic_='Pictures' \
        vid_='Videos' \
        aUser_=$adminUser_ \
        sS1_='' sS2_='' searchZfs='';
  local zD_=$d_ \
        zDp_='DataPool';
  echo '';

  # cat /etc/fstab | grep "Data" | grep -v "DataPool"

  mkdir -p ~/.config;
  if [ -f "$configF_" ]; then
     sS1_=$(echo $(cat $configF_ | grep -oF "$conf_" ));
     if [ "$sS1_" == "$conf_" ]; then echo $m1_; sleep 5; return; fi;
  fi;

  sS1_='/'$d_;    # /Data
  if [ ! -d "$sS1_" ]; then \
     echo '/Data directoty does not exist in the system...'; sleep 5; return; fi;

  echo $m0_;
  sudo mkdir -p /$d_;
  sudo chown -R $aUser_:$aUser_ /$d_;
  chmod -R 775 /$d_;
   
  echo "";
  echo "Creating Documents directories...";
  mkdir -p /$d_/$doc_;
  mkdir -p /$d_/$doc_/$dow_;
  mkdir -p /$d_/$doc_/$mus_;
  mkdir -p /$d_/$doc_/$pic_;
  mkdir -p /$d_/$doc_/$vid_;

  sudo rm -rf /$h_/$aUser_/$doc_;
  sudo rm -rf /$h_/$aUser_/$dow_;
  sudo rm -rf /$h_/$aUser_/$mus_;
  sudo rm -rf /$h_/$aUser_/$pic_;
  sudo rm -rf /$h_/$aUser_/$vid_;

  ln -s /$d_/$doc_ /$h_/$aUser_/$doc_;
  ln -s /$d_/$doc_/$dow_ /$h_/$aUser_/$dow_;
  ln -s /$d_/$doc_/$mus_ /$h_/$aUser_/$mus_;
  ln -s /$d_/$doc_/$pic_ /$h_/$aUser_/$pic_;
  ln -s /$d_/$doc_/$vid_ /$h_/$aUser_/$vid_;

  mkdir -p /$d_/$doc_/ToShare-FullAccess;
  mkdir -p /$d_/$doc_/ToShare-JustRead;

  chmod 777 /$d_/$doc_/ToShare-FullAccess;
  chmod 777 /$d_/$doc_/ToShare-JustRead;

  echo "Deleting $configF_ configuration file...";
  rm -rf $configF_;

  echo "Creating new $configF_ configuration file...";

cat <<"EOT">> $configF_;

# -  - #
# - Configured - #
# - nvim ~/.config/user-dirs.dirs - #
# -  - #

XDG_DOCUMENTS_DIR="/$d_/$doc_"
XDG_DOWNLOAD_DIR="/$d_/$doc_/$dow_"
XDG_MUSIC_DIR="/$d_/$doc_/$mus_"
XDG_PICTURES_DIR="/$d_/$doc_/$pic_"
XDG_VIDEOS_DIR="/$d_/$doc_/$vid_"

EOT

  sed -i '7 i XDG_DESKTOP_DIR="$HOME/Desktop"' $configF_;
  sed -i '8 i XDG_TEMPLATES_DIR="$HOME/Templates"' $configF_;
  sed -i '9 i XDG_PUBLICSHARE_DIR="$HOME/Public"' $configF_;

  echo -e "\n$DDir_ have been configured...";
  sleep 10;
}



# -  - #
# - Brave_ - #
function Brave_(){
  local bWServer_=$uWServer_$sAws_ \
        sD_=~/Downloads/ \
        bTar_=Brave.tar.bz2 \
        aHome_=~/.local/share/applications/ \
        aF_=Brave.desktop \
        bImage_=Brave-Web-Browser-Debian-x86-64.AppImage \
        iHome_=~/.AppImages/ \
        bF_=Brave \
        bIcon_=Brave.png;

  echo "";
  echo "Installing $bF_...";

<<'comment'
  mkdir -p ~/.local/share/applications;
  mkdir -p ~/.AppImages/Brave;
comment

  mkdir -p $aHome_ $iHome_$bF_;
  rm -rf $aHome_$aF_;


cat <<EOT >> $aHome_$aF_;
[Desktop Entry]
Type=Application
Name=$bF_
Comment=Internet browser
Exec=$iHome_$bF_/$bImage_
Icon=$iHome_$bF_/$bIcon_
Terminal=false
StartupWMClass=$bF_
StartupNotify=false
Categories=Network;
EOT

  cd $sD_;

  # -  - #
  # - ~/Downloads/Brave.tar.bz2 - #
  curl -O $bWServer_$bTar_;

  # -  - #
  # - Untar - #
  tar -xvf $bTar_;

  cd $bF_.Ins;
  chmod +x $bImage_;

  mv $bImage_ $bIcon_ $iHome_$bF_;
  cd ..;
  rm -rf $bF_.*;

  cd $Dir_;
  echo "";
  sleep 10;
}




# -  - #
# - ClipGrab_ - #
function ClipGrab_(){
  local bWServer_=$uWServer_$sAws_ \
        sD_=~/Downloads/ \
        bTar_=ClipGrab.tar.bz2 \
        aHome_=~/.local/share/applications/ \
        aF_=ClipGrab.desktop \
        bImage_=ClipGrab-3.9.10-x86_64.AppImage \
        iHome_=~/.AppImages/ \
        bF_=ClipGrab \
        bIcon_=ClipGrabIcon1.png;

  echo -e "\nInstalling $bF_...";

<<'comment'
  mkdir -p ~/.local/share/applications;
  mkdir -p ~/.AppImages/ClipGrab;
comment

  mkdir -p $aHome_ $iHome_$bF_;
  rm -rf $aHome_$aF_;

cat <<EOT >> $aHome_$aF_;
[Desktop Entry]
Type=Application
Name=$bF_
Comment=Youtube video downloader
Exec=$iHome_$bF_/$bImage_
Icon=$iHome_$bF_/$bIcon_
Terminal=false
StartupWMClass=$bF_
StartupNotify=false
Categories=Network;
EOT

  cd $sD_;
  
  # -  - #
  # - ~/Downloads/ClipGrab.tar.bz2 - #
  curl -O $bWServer_$bTar_;
  
  # -  - #
  # - Untar - #
  tar -xvf $bTar_;
  
  cd $bF_.Ins;
  chmod +x $bImage_;

  mv $bImage_ $bIcon_ $iHome_$bF_;
  cd ..;
  rm -rf $bF_.*;

  cd $Dir_;
  echo "";
  sleep 10;
}



# -  - #
# - BalenaEtcher_ - #
function BalenaEtcher_(){
  local bWServer_=$uWServer_$sAws_ \
        sD_=~/Downloads/ \
        bTar_=BalenaEtcher.tar.bz2 \
        aHome_=~/.local/share/applications/ \
        aF_=BalenaEtcher.desktop \
        bImage_=balenaEtcher-1.5.109-x64.AppImage \
        iHome_=~/.AppImages/ \
        bF_=BalenaEtcher \
        bIcon_=BalenaEtcher2.png;

  echo -e "\nInstalling $bF_...";

<<'comment'
  mkdir -p ~/.local/share/applications;
  mkdir -p ~/.AppImages/BalenaEtcher;
comment

  mkdir -p $aHome_ $iHome_$bF_;
  rm -rf $aHome_$aF_;

cat <<EOT >> $aHome_$aF_;
[Desktop Entry]
Type=Application
Name=$bF_
Comment=Burn ISO files to USB stick
Exec=$iHome_$bF_/$bImage_
Icon=$iHome_$bF_/$bIcon_
Terminal=false
StartupWMClass=$bF_
StartupNotify=false
Categories=System;
EOT

  cd $sD_;
  
  # -  - #
  # - ~/Downloads/BalenaEtcher.tar.bz2 - #
  curl -O $bWServer_$bTar_;
  
  # -  - #
  # - Untar - #
  tar -xvf $bTar_;
  
  cd $bF_.Ins;
  chmod +x $bImage_;

  mv $bImage_ $bIcon_ $iHome_$bF_;
  cd ..;
  rm -rf $bF_.*;

  cd $Dir_;
  echo "";
  sleep 10;
}



# -  - #
# - cleaning_ - #
function cleaning_(){

  echo -e "\nCleaning system cache...";
  sudo pacman -Scc --noconfirm;

  echo 'Removing orphan packages...';
  sudo pacman -R $(pacman -Qtdq) --noconfirm;

  echo 'Cleaning user cache...';
  sudo du -sh ~/.cache/;
  rm -rf ~/.cache/*;
  sudo rm -rf ~/.cache/*;

  echo -e "Cleaning done...\n";
}



# -  - #
# - aDConf_ - #
function aDConf_(){
  local sS_=$aSoftware_ \
        tmp_=~/tmp.txt;
  echo -e "\nCreating $aDesktopConf_ configuration file...";

  rm -rf $tmp_;

cat <<"EOT">> $tmp_;
# - bof - #

$sS_



# - eof - #
EOT

  sudo mv $tmp_ $aDesktopConf_;
  sudo chown -R root:root $aDesktopConf_;
  echo -e "\n\n";
}



# -  - #
# - samba - #
function samba_(){
  local sWs_=$uWServer_'Arch.Ins/Software.Ins/Bashrc-Zshrc.Ins/' \
        sH_=/etc/samba/smb.conf \
        sF_=smb.conf \
        gF_=/etc/group \
        pF_=/etc/passwd \
        sS_=sambashare \
        sU_='smbguest' \
        aU_=$adminUser_ \
        aP_=$adminPasswd_;
  local m0_='Configuring '$sH_' ...' \
        m1_=$sH_' already configured...' \
        sS1_="# - Configured - #" sS2_='' sS3_='' sS4_='';
  echo "";

  if [ -f "$sH_" ]; then
    sS2_=$(echo $(cat $sH_ | grep "$sS1_" ));
    if [ "$sS2_" == "$sS1_" ]; then echo $m1_; sleep 5; return; fi;
  fi;

  echo $m0_;

  echo -e "\nCreating $sS_ group...";
  sudo groupadd -r $sS_;

  echo "Creating $sU_ user...";
  sudo useradd -r -s /usr/bin/nologin $sU_;

  echo "Creating $sU_ user password...";
  (echo $sU_; sleep 1; echo $sU_ ) | sudo passwd $sU_;

  echo "Adding $sU_ user to $sS_ group...";
  sudo usermod -aG $sS_ $sU_;

  echo "Adding $aU_ user to $sS_ group...";
  sudo usermod -aG $sS_ $aU_;

  echo "Enabling $sU_ user in samba...";
  sudo gpasswd $sS_ -a $sU_;

  echo "Enabling $aU_ user in samba...";
  sudo gpasswd $sS_ -a $aU_;

  echo "Creating $sU_ user password on samba...";
  (echo $sU_; sleep 1; echo $sU_ ) | sudo pdbedit -a -u $sU_;

  echo "Creating $aU_ user password on samba...";
  (echo $aP_; sleep 1; echo $aP_ ) | sudo pdbedit -a -u $aU_;

  echo "";
  cat $gF_ | grep $sU_;
  cat $gF_ | grep $aU_;

  cat $pF_ | grep $sU_;
  cat $pF_ | grep $aU_;


  echo -e "\nGenerating $sH_..."

  cd ~/;
  curl $sWs_$sF_ -o $sF_;
  sed -i "s/adminUser_/$aU_/" $sF_;
  sudo mv $sF_ $sH_;

  echo -e "\nRestart samba service...";
  sudo systemctl enable --now smb nmb;
  sudo systemctl start smb.service nmb.service
  echo -e "\n$sH_ has been configured...\n";
  sleep 10;
}



# -  - #
# - sPackages_ - #
function sPackages_(){
  local sS1_='' sS2_='' sS3_='' sS4_='' 
        lPacks_=$1 ;
  
  while true;
  do
    sS1_=$(echo "$lPacks_" | awk '{print $1}');
    lPacks_=$(echo "${lPacks_/$sS1_/"$sS2_"}");

    sS4_=$(echo $(pacman -Ssq | grep -oF "$sS1_" ) | awk '{print $1;}' );
    if [ "$sS4_" != "" ]; then
      sS3_=$sS3_" "$sS1_;
    else
      echo -e "$sS1_" >> $logF_;
    fi;
    sS1_='';

    lPacks_=$(echo "$lPacks_" | xargs);
    if [[ "$lPacks_" == "" ]]; then
      break; fi;
  done

  echo $sS3_;
}



# -  - #
# - checkComputer_ - #
function checkComputer_(){
  local sMsg_="This process cannot be executed on: $hostName_...";
  echo -e '\nChecking computer...\n';
  if [ "$hostName_" == "HPLaptopArch" ] || [ "$hostName_" == "HPDesktopArch" ]; then
    rm -rf ~/Arch_PostInstallation.sh;
    echo -e "\n$sMsg_\n\n\n";
    sleep 10;
    exit;
  fi;
  echo "";
}



Header_;
Greetings_;
checkComputer_;
AdditionalSoftware_;
bashrc_;
DataBtrfs_;
DataDirectories_;
samba_;



rm -rf ~/Arch_PostInstallation.sh;
cleaning_;



echo -e "\n\nPost installation is done...";
echo -e "System will reboot now so changes will reflect...\n\n\n";
sleep 10;



sudo reboot now;



<<'comment'
cd ~/; rm -rf ~/Arch_PostInstallation.sh; nvim ~/Arch_PostInstallation.sh;
copy & paste this content
chmod +x ~/Arch_PostInstallation.sh; ~/./Arch_PostInstallation.sh;
comment



# - eof - #