#!/bin/bash
# - bof - #



<<'comment'



sh -c "$(curl -fsSL https://www.education.isdevelopment.us/Arch.Ins/50-Arch_Xfce-FinalConfiguration.sh)"



# :A
# -  - #
# - Arch Xfce final configuration script - #

# - Method   # 1 - #
sh -c "$(curl -fsSL https://www.education.isdevelopment.us/Arch.Ins/50-Arch_Xfce-FinalConfiguration.sh)"

# - Method   # 2 - #
xfC_=Arch_Xfce-FinalConfiguration.sh;
curl -o ~/$xfC_ https://www.education.isdevelopment.us/Arch.Ins/50-$xfC_;
vim ~/$xfC_;
chmod +x ~/$xfC_; ~/./$xfC_;

# - Method   # 3 - #
cd ~/; rm -rf ~/Arch_Xfce-FinalConfiguration.sh; nvim ~/Arch_Xfce-FinalConfiguration.sh;
copy & paste this content
chmod +x ~/Arch_Xfce-FinalConfiguration.sh; ~/./Arch_Xfce-FinalConfiguration.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 - #
Dir_=($PWD);
hostName_=$(echo $(uname -n));

uWServer_="https://www.education.isdevelopment.us";



Plank_='No';
Plank_='Yes';

Desktop_=1;      # 1.Xfce 2.Cinnamon 3.Kde-Plasma 4.Gnome 5.Deepin 6.Budgie 7.OpenBox 8.XMonad 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 the Xfce-Desktop final configuration"
  echo "";
  echo "Important: This procedure will take a few minutes.";
  echo "";
  echo "Procedure: Open terminal & paste next command:";
  echo "";
  echo '           sh -c "$(curl -fsSL https://www.education.isdevelopment.us/Arch.Ins/50-Arch_Xfce-FinalConfiguration.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_Xfce-FinalConfiguration.sh;
          exit;
          break;;
        * ) echo "Please answer (y)es or (n)o.";;
    esac
done
}



# -  - #
# - Header_ - #
function Header_(){
  clear;
  echo "";
  figlet -f small "Xfce Desktop" | lolcat;
  figlet -f small "Final Configuration" | lolcat;
}



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



# -  - #
# - Configuring system - #
function ConfiguringSystem_(){
  local sPhase_=$1;

  if [ "$sPhase_" == "1" ]; then
    Wallpapers_;
    if [ "$Plank_" == "Yes" ]; then
      PlankThemes_; fi;
  fi;

  # 1.Xfce 2.Cinnamon 3.Kde-Plasma 4.Gnome 5.Deepin 6.Budgie 7.OpenBox 8.XMonad 9.NoDesktop
  if [ "$Desktop_" == "1" ]; then
    if [ "$sPhase_" == "1" ]; then
      XfceDesktopProgramsShortcuts_; fi;

     # WhiskerMenu_;
    dotConfig_Xfce_ $sPhase_;
  elif [ "$Desktop_" == "7" ]; then
     dotConfig_OpenBox_ $sPhase_;
  fi;

  FirefoxConfiguration_ $sPhase_;
  Lightdm_GTK_Greeter_ $sPhase_;
}



# -  - #
# - WhiskerMenu_ - #
function WhiskerMenu_(){
  local whiskermenuF_=~/.config/xfce4/panel/whiskermenu-1.rc \
favorites_='favorites=org.manjaro.pamac.manager.desktop,org.gnome.FileRoller.desktop,org.bleachbit.BleachBit.desktop,org.gnome.Calculator.desktop,org.gnome.DiskUtility.desktop,simple-scan.desktop,org.kde.dolphin.desktop,org.kde.filelight.desktop,filezilla.desktop,firefox.desktop,gparted.desktop,org.kde.kpat.desktop,libreoffice-calc.desktop,libreoffice-writer.desktop,lightdm-gtk-greeter-settings.desktop,pinta.desktop,system-config-printer.desktop,xfce-settings-manager.desktop,org.kde.spectacle.desktop,org.gnome.gedit.desktop,thunar.desktop,com.gexperts.Tilix.desktop,transmission-gtk.desktop';
  echo -e "\nConfiguring whisker menu...";
  sed -i '1 i '$favorites_ $whiskermenuF_;
  sed -i '2 d' $whiskermenuF_;
  echo -e "\nWhisker menu was configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - Wallpapers_ - #
function Wallpapers_(){
  local sWs_=/Arch.Ins/Software.Ins/ \
        sF_=Various.zip;

  echo -e "\n\nDownloading wallpapers...\n";
  cd ~/Pictures;
  curl -O $uWServer_$sWs_$sF_;
  unzip $sF_;

  echo -e "\n\n\nCopying backgrounds files...\n";
  sudo mkdir -p /usr/share/backgrounds;
  sudo mv Various /usr/share/backgrounds/;
  sudo mv Archlinux-icon-crystal_13.png /usr/share/backgrounds/;
  rm -rf Various*;
  cd $Dir_;

  echo -e "\nWallpaper were configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - FirefoxConfiguration_ - #
function FirefoxConfiguration_(){
  local sPhase_=$1;
  local sWs_=/Arch.Ins/Software.Ins/ \
        sF_=FirefoxConfigurationFiles.tar.bz2;

  echo -e "\nDownloading firefox configuration files...\n";

<<'comment'
  # -  - #
  # - Documentation - #
  https://www.addictivetips.com/ubuntu-linux-tips/backup-and-restore-a-firefox-profile-on-linux/
  tar -jcvf FirefoxConfigurationFiles.tar.bz2 ~/.mozilla;
comment

  cd ~/Downloads;
  if [ "$sPhase_" == "1" ]; then
    curl -O $uWServer_$sWs_$sF_; fi;

  echo -e "\n\n\nApplying firefox configuration files...\n";
  rm -rf ~/.mozilla;
  sleep 2;
  rm -rf ~/.mozilla;

  tar -xvf $sF_ -C ~/ --wildcards *.mozilla;
  if [ "$sPhase_" == "2" ]; then
    rm -rf $sF_; fi;

  cd $Dir_;
  echo -e "\nFirefox was configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - Lightdm_GTK_Greeter_ - #
function Lightdm_GTK_Greeter_(){
  lightdmF_=/etc/lightdm/lightdm-gtk-greeter.conf;

  echo -e "\nConfiguring $lightdmF_...";

  echo '[greeter]' | sudo tee $lightdmF_ > /dev/null;
  sudo sed -i '$ a theme-name = Arc-Dark' $lightdmF_;
  sudo sed -i '$ a icon-theme-name = Arc' $lightdmF_;
  sudo sed -i '$ a default-user-image = /usr/share/backgrounds/Archlinux-icon-crystal_13.png' $lightdmF_;
  
  if [ "$Desktop_" == "1" ]; then
    sudo sed -i '$ a background = /usr/share/backgrounds/Various/FavoriteWallpaper.jpg' $lightdmF_;
  else
    sudo sed -i '$ a background = /usr/share/backgrounds/Various/conference.png' $lightdmF_;
  fi;
  
  sudo sed -i '$ a reader = xrandr --output Virtual-1 --primary --mode 1920x1080' $lightdmF_;
  sudo sed -i '$ a a11y-states = +reader' $lightdmF_;
  
  echo -e "\n$lightdmF_ was configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - PlankThemes_ - #
function PlankThemes_(){
  local PlankThemes=/Arch.Ins/Software.Ins/PlankThemes.zip \
        sThe_=/usr/share/plank/themes \
        ;
  echo -e "\nDownloading plank themes...\n";
  cd ~/Downloads;
  curl -O $uWServer_$PlankThemes;
  unzip PlankThemes.zip;

  echo "Copying plank themes...";
  sudo rm -rf $sThe_;
  sudo mkdir -p $sThe_;

  sudo mv ~/Downloads/plank/themes/* $sThe_;
  rm -rf ~/Downloads/plank*;
  rm -rf ~/Downloads/PlankThemes.*;
  cd $Dir_;

  echo -e "\nPlank themes were configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - dotConfig_Xfce_ - #
function dotConfig_Xfce_(){
  local sPhase_=$1;
  local sUsr_=($USER) \
        aUsr_='is_derayo' \
        wF_=/Arch.Ins/Software.Ins/ \
        sF_=Xfce_DesktopConfigurationFiles.tar.bz2;
  local sPlk_=/home/$sUsr_/.config/plank/dock1/launchers/;
  local sDsk_=$sPlk_"Disk-1.dockitem" \
        sDoc_=$sPlk_"Documents.dockitem" \
        sSys_=$sPlk_"System-1.dockitem";
  local sJson_=/home/$sUsr_/.config/yay/config.json;

  echo -e "\nDownloading configuration files...\n";

  cd ~/Downloads;
  if [ "$sPhase_" == "1" ]; then
    curl -O $uWServer_$wF_$sF_; fi;

  echo -e "\nApplying configuration files...\n";
  rm -rf ~/.config;
  sleep 2;
  rm -rf ~/.config;

  tar -xvf $sF_ -C ~/ --wildcards *.config;

<<'comment'
  tar -xvf $dotConf_Xfce_Downloads -C ~/Downloads --wildcards \
            *libreoffice --wildcards *BraveSoftware;
comment

  if [ "$sPhase_" == "2" ]; then
    rm -rf $sF_; fi;



  if [ "$sUsr_" != "$aUsr_" ]; then
    rm -rf $sDsk_ $sDoc_ $sSys_;

    echo -e "[PlankDockItemPreferences]" > $sDsk_;
    echo -e "Launcher=file:///home/"$sUsr_"/Desktop/Disk" >> $sDsk_;

    echo -e "[PlankDockItemPreferences]" > $sDoc_;
    echo -e "Launcher=file:///home/"$sUsr_"/Desktop/Documents" >> $sDoc_;

    echo -e "[PlankDockItemPreferences]" > $sSys_;
    echo -e "Launcher=file:///home/"$sUsr_"/Desktop/System" >> $sSys_;

    sed -i 's/'"$aUsr_"'/'"$sUsr_"'/' $sJson_;
  fi;



  cd $Dir_;
  echo -e "\nConfiguration files were applied successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - dotConfig_OpenBox_ - #
function dotConfig_OpenBox_(){
  local sPhase_=$1;
  local wF_=/Arch.Ins/Software.Ins/ \
        sF_=dotConfig_OpenBox.tar.bz2;
        dotConfig_OpenBox_=/Images/Programs/Linux.Img/Linux_Arch.Img/Arch_Install/TilingWindowManager/OpenBoxInstall/dotConfig_OpenBox.tar.bz2 \

  echo -e "\n\nDownloading configuration files...\n";

<<'comment'
  # -  - #
  # - Documentation - #
  tar -jcvf DesktopConfigurationFiles.tar.bz2 ~/.config;
comment

  cd ~/Downloads;
  if [ "$sPhase_" == "1" ]; then
    curl -O $uWServer_$wF_$sF_; fi;

  echo -e "\n\nApplying configuration files...\n";

  tar -xvf $sF_ -C ~/ --wildcards *libreoffice;
  tar -xvf $sF_ -C ~/ --wildcards *gtk-*;
  tar -xvf $sF_ -C ~/ --wildcards *gedit;


  if [ "$sPhase_" == "2" ]; then
    rm -rf $sF_; fi;

  cd $Dir_;
  echo -e "\n\nConfiguration files were applied successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - XfceDesktopProgramsShortcuts_ - #
function XfceDesktopProgramsShortcuts_(){
  local wF_=/Arch.Ins/Software.Ins/ \
        sF_=Xfce_DesktopPrograms-Shortcut.zip \
        sD_=~/Desktop/ \
        sDoc_=~/Downloads/Documents \
        sDsk_=~/Downloads/Disk \
        sSys_=~/Downloads/System;

  echo -e "\n\nDownloading Xfce desktop programs shortcuts...";

  rm -rf $sDoc_ $sDsk_ $sSys_;

  cd ~/Downloads;
  curl -O $uWServer_$wF_$sF_;
  unzip $sF_;

  echo -e "\n\nCopying desktop programs shortcuts...\n";

  rm -rf $sD_'Documents' $sD_'Disk' $sD_'System';

  mv $sDoc_ $sD_;
  mv $sDsk_ $sD_;
  mv $sSys_ $sD_;

  rm -rf $sF_;
  cd $Dir_;

  echo -e "\n\nXfce desktop programs shortcuts were configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - 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_Xfce-FinalConfiguration.sh;
    echo -e "\n$sMsg_\n\n\n";
    sleep 10;
    exit;
  fi;
  echo "";
}



Header_;
Greetings_;
checkComputer_;
Update_;

ConfiguringSystem_ 1;
echo -e "\n\nSystem configured successfully on the first phase...";
sleep 10;

ConfiguringSystem_ 2;

rm -rf ~/Arch_FinalConfiguration.sh;

echo -e "\n\nSystem configured successfully on the final phase...";
echo -e "\n\nComputer will reboot so all changes are applied...";
sleep 10;



sudo reboot now;



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



# - eof - #