# - bof - #



<<'comment'
# -  - #
# - Add Functions.sh to any bash file - #

# -  - #
# - Esencial software - #
xdg-user-dirs-update;
sudo apt install dialog duf curl figlet git lolcat neovim pv webapp-manager -y;
sudo apt install dialog duf curl figlet git htop inxi lolcat net-tools neovim openssh-server pv webapp-manager -y;


source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)
lightVersion_=$( lVersion_ );
distroVersion_;


# -  - #
# - Timezone - #
sudo timedatectl set-ntp true;
sudo timedatectl set-timezone America/New_York;
timedatectl status;
timedatectl;



echo $XDG_CURRENT_DESKTOP;
echo $DESKTOP_SESSION;

comment



Opt=0;
Dir_=($PWD);
uWServer_="https://www.education.isdevelopment.us"
aDesktopConf_=/etc/aDesktop.Conf;

if [ "$hostName_" = "" ]; then
    hostName_=$(uname -n); fi;

# -  - #
# - Documentation - #
# https://wiki.archlinux.org/title/Xfce
bGpicture='Garage.jpg';
bGround_=/usr/share/backgrounds/Various/$bGpicture;



# -  - #
# - checkComputer_ - #
function checkComputer_(){
  local sMsg_="This process cannot be executed on: $hostName_..." \
        sFile_=$1;

  if [ "$overwriteCc_" == "Yes" ]; then
    return; fi;

  echo -e '\nChecking computer...\n';
  if [ "$hostName_" == "HPLaptopArch" ] || [ "$hostName_" == "HPDesktopZorin" ]; then
    if [ "$sFile_" != "" ]; then
      rm -rf ~/$sFile_; fi;
    clear;
    echo -e "\n\n\n$sMsg_\n\n\n";
    sleep 10;
    exit;
  fi;
  echo "";
}



# -  - #
# - uwoeUsb_ - #
function uwoeUsb_(){
  local wUsb_='WoeUsb';
  echo -e "\n\n\nIsntalling $wUsb_...\n";
  sudo add-apt-repository ppa:tomtomtom/woeusb -y;
  sudo apt update && sudo apt upgrade -y --autoremove && sudo apt clean;
  sudo apt install woeusb woeusb-frontend-wxgtk -y;
  echo -e "\n$wUsb_ was installed successfully...\n";
}



# -  - #
# - update_ - #
function update_(){
  echo -e "\n\nUpdating the system...\n\n";
  case $Opt in
    1 | 4 | 5 )
      # - ubuntu, debian, linuxmint, zorin - #
      sudo apt update && sudo apt upgrade -y --autoremove && sudo apt clean;        
      ;;
    2 )
      # - arch - #
      sudo pacman -Syu --noconfirm && sudo pacman -Syyuu --noconfirm;        
      ;;
    3 )
      # - fedora - #
      sudo dnf update -y;        
      ;;
  esac
  echo -e "\n\nThe System was updated successfuly...\n\n\n";
  sleep 5;
}



# -  - #
# - distroVersion_ - #
function distroVersion_() {
  # Default fallback
  Opt=0 

  # 1. Try /etc/os-release first (The modern standard)
  if [[ -f /etc/os-release ]]; then
    local ID="" ID_LIKE=""
    
    # Safely parse keys and convert values to lowercase universally
    while IFS='=' read -r key value; do
      value="${value%\"}"
      value="${value#\"}"
      
      # FIX: Works flawlessly in BOTH Bash and Zsh
      if [[ "$key" == "ID" ]]; then
        ID=$(echo "$value" | tr '[:upper:]' '[:lower:]')
      elif [[ "$key" == "ID_LIKE" ]]; then
        ID_LIKE=$(echo "$value" | tr '[:upper:]' '[:lower:]')
      fi
    done < /etc/os-release

    # Match against ID
    case "$ID" in
      debian|ubuntu|linuxlite)             Opt=1 ;;
      arch|artix)                          Opt=2 ;;
      fedora|rhel|centos|amzn)             Opt=3 ;;
      zorin)                               Opt=4 ;;
      linuxmint)                           Opt=5 ;;
      *)
        # If ID didn't match, check ID_LIKE as a fallback helper
        case "$ID_LIKE" in
          *debian*|*ubuntu*)               Opt=1 ;;
          *arch*)                          Opt=2 ;;
          *fedora*|*rhel*|*centos*)        Opt=3 ;;
        esac
        ;;
    esac

    # If we successfully matched something, we can return early
    if [[ $Opt -ne 0 ]]; then
      return
    fi
  fi

  # 2. Fallback to /proc/version only if /etc/os-release wasn't enough
  local version_info
  version_info=$(tr '[:upper:]' '[:lower:]' < /proc/version)

  case "$version_info" in
    *debian*|*ubuntu*)                     Opt=1 ;;
    *arch*)                                Opt=2 ;;
    *fedora*|"*red hat*"|*rhel*|*centos*)  Opt=3 ;;
  esac
}



# -  - #
# - Tilix_ - #
function Tilix_(){
  local sT_=Tilix;

  if [ "$( which tilix )" != "" ]; then
    sleep 5; exit 0; fi;

  echo -e "\nInstalling $sT_...\n";

  flatpak install fedora com.gexperts.$sT_ -y;

  echo -e "\n$sT_ was installed successfully...\n\n\n";
}



# -  - #
# - weztermConfiguration_ - #
function weztermConfiguration_(){
  local sMsg_="Configuring wezTerm..." \
        eWs_="/wezTerm/wezTerm-Configuration/" \
        wTar_=wezTem.tar.bz2 \
        wD_=~/.config/wezterm/ \
        sDwn_=~/Downloads;
  local bWServer_=$uWServer_$eWs_$wTar_;

  echo -e "\n\n$sMsg_\n\n";
  mkdir -pv $wD_;
  mkdir -p $sDwn_;
  cd $sDwn_;

  # -  - #
  # - ~/Downloads/wezTem.tar.bz2 - #
  curl -O $bWServer_;
  echo -e "\n";
  tar -xvf $wTar_ -C ~/;
  rm -rf $wTar_;



  # -  - #
  # - Create wezterm autostart - #
  mkdir -p ~/.config/autostart;

cat << EOF > ~/.config/autostart/wezterm.desktop
[Desktop Entry]
Type=Application
Exec=wezterm
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=WezTerm
Comment=Start WezTerm at login
EOF



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



# -  - #
# - wezTerm_ - #
function wezTerm_(){
  local sWt_=wezterm;
  echo -e "\nInstalling $sWt_...\n";
  installFlatpak_;
  case $Opt in
    1)
      flatpak install flathub org.wezfurlong.$sWt_ -y;
      sudo apt install fonts-font-awesome -y;
      ;;
    2)
      sudo pacman -S wezterm --noconfirm --needed;
      sudo pacman -S ttf-font-awesome --noconfirm --needed;
      ;;
    3)
      flatpak install flathub org.wezfurlong.$sWt_ -y;
      sudo dnf install fontawesome-fonts-all -y;
      ;;
  esac
  echo -e "\n$sWt_ was installed successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - installFlatpak_ - #
function installFlatpak_(){
  local sFp_=flatpak;
  echo -e "\n\nInstalling $sFp_...\n\n";
  case $Opt in
    1)
      sudo apt install $sFp_ -y 
      ;;
    2)
      sudo pacman -S $sFp_ --noconfirm --needed;
      ;;
    3)
      sudo dnf install $sFp_ -y;
      ;;
  esac
  echo -e "\n\n$sFp_ was installed successfully...\n\n\n";
  sleep 10;

  remotesAdd_;
}



# -  - #
# - remoteAdd_ - #
function remotesAdd_(){
  echo -e "\n\nInstalling flatpak remotes...\n";

  flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
  flatpak remote-add --if-not-exists gnome-nightly https://nightly.gnome.org/gnome-nightly.flatpakrepo
  flatpak remote-add --if-not-exists appcenter https://flatpak.elementary.io/repo.flatpakrepo

<<'comment'
  flatpak remote-add --if-not-exists fedora oci+https://registry.fedoraproject.org
  flatpak remote-add --if-not-exists webkit-sdk https://software.igalia.com/flatpak-refs/webkit-sdk.flatpakrepo
  flatpak remote-add --if-not-exists zorinos https://flatpak.zorinos.com/repo/
  flatpak remote-add --no-gpg-verify zorinos https://flatpak.zorinos.com/repo/
comment

  echo -e "\nFlatpak remotes were installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - debugFlatpak_ - #
function debugFlatpak_() {
  echo -e "\n=== Flatpak Debug Info ===\n"
  
  echo "Remotes:"
  flatpak remotes -d
  
  echo -e "\nInstalled Flatpaks:"
  flatpak list
  
  echo -e "\n=== End Debug ===\n"
  sleep 5
}



# -  - #
# - wareHouse_ - #
function wareHouse_(){
  local sWh_="Warehouse";
  echo -e "\n\nInstalling $sWh_...\n\n";

  flatpak install flathub io.github.flattool.Warehouse -y --noninteractive;

  echo -e "\n\n$sWh_ was installed successfully...\n\n\n";
  sleep 10;
  
  flatpakSoftware_;

  if [ "$lightVersion_" == "No" ]; then
    flatpakStudio_; fi;
}



# -  - #
# - flatpakSoftware_ - #
function flatpakSoftware_(){
  local sWh_="flatpak software";
  echo -e "\n\nInstalling $sWh_...\n\n";

  # -  - #
  # - PDF viewer - pick ONE (Papers is lighter, Okular has more features) - #
  flatpak install flathub org.kde.okular -y --noninteractive;
  flatpak install flathub org.gnome.Papers -y --noninteractive;

  # -  - #
  # - VS Code - #
    flatpak install flathub com.visualstudio.code -y --noninteractive;

<<'comment'
  flatpak install fedora com.gexperts.Tilix -y;
  flatpak install flathub arcmenu@arcmenu.com -y

  # -  - #
  # - VS Code extensions (If needed) - #
  extensions=(org.freedesktop.Sdk.Extension.dotnet org.freedesktop.Sdk.Extension.golang)
  flatpak install flathub "${extensions[@]}" -y --noninteractive

  Available extensions for vsCode:
    dotnet
    golang
    node14, node16, node18, node20
    python3
    rust-stable
comment

  echo -e "\n\n$sWh_ was installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - flatpakStudio_ - #
# Optional creative software suite (audio/video/graphics)
function flatpakStudio_(){
  clear
  echo -e "\n\n\n\n\n\n"

  figlet "Flatpak" | lolcat
  figlet "Studio Software" | lolcat

  echo -e "\n\n\n"

  while true; do
    read -p "Install Flatpak Studio Software (Photopea, OBS, Natron, Darktable, Kdenlive, Krita, Inkscape)? (y/n): " yn
    case $yn in
        [Yy]* )
          echo -e "\n\nInstalling Studio Software...\n\n"

          # Image editors
          flatpak install flathub com.github.vikdevelop.photopea_app -y --noninteractive
          flatpak install flathub org.inkscape.Inkscape -y --noninteractive
          flatpak install flathub org.kde.krita -y --noninteractive
          
          # Photo management
          flatpak install flathub org.darktable.Darktable -y --noninteractive
          
          # Video editors
          flatpak install flathub org.kde.kdenlive -y --noninteractive
          flatpak install flathub fr.natron.Natron -y --noninteractive
          
          # OBS Studio - use flathub, not fedora repo
          flatpak install flathub com.obsproject.Studio -y --noninteractive

          echo -e "\n\nStudio software installed successfully...\n\n\n"
          sleep 10
          break
          ;;
        [Nn]* )
          echo -e "\n\nSkipping Studio software installation...\n\n"
          sleep 2
          break
          ;;
        * )
          echo "Please answer (y)es or (n)o."
          ;;
    esac
  done
}



# -  - #
# - uAdditionalSoftware_ - #
function uAdditionalSoftware_(){
  local aS_="Additional software";
  echo -e "\n\nInstalling $aS_...\n\n";

  lPrograms1_="arc-theme curl duf evince extlinux fastfetch figlet filelight file-roller firefox gedit git \
               gparted gvfs gvfs-backends gvfs-fuse htop lolcat lsb-release mhddfs neovim net-tools openssh-client \
               openssh-server pv screenfetch sshfs synaptic testdisk thunar tree unzip wget whois zip";
  sPackages_ "$lPrograms1_";

  echo -e "\n\n$aS_ was installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - Log_ - #
function Log_(){
  local nO_=$1 \
        sM1_="ArchInstall\nPrograms not installed:" \
        sM2_="Arch_PostInstallation\nPrograms not installed:" \
        sM3_="Arch_Xfce-Desktop-Install\nPrograms not installed:" \
        sM4_="Arch_Cinnamon-Desktop-Install\nPrograms not installed:" \
        sM5_="Arch_Gnome-Desktop-Install\nPrograms not installed:" \
        sM6_="Arch_PlasmaKDE-Desktop-Install\nPrograms not installed:" \
        sM7_="Ubuntu Desktop ProgramsListInstallation\nPrograms not installed:";

  if [ -f "$logF_" ]; then
    rm -rf $logF_; fi;

  if [ "$nO_" == "1" ]; then
    lMsg_=$sM1_;
  elif [ "$nO_" == "2" ]; then
    lMsg_=$sM2_;
  elif [ "$nO_" == "3" ]; then
    lMsg_=$sM3_;
  elif [ "$nO_" == "4" ]; then
    lMsg_=$sM4_;
  elif [ "$nO_" == "5" ]; then
    lMsg_=$sM5_;
  elif [ "$nO_" == "6" ]; then
    lMsg_=$sM6_;
  elif [ "$nO_" == "7" ]; then
    lMsg_=$sM7_;
  fi;

  echo -e "$lMsg_\n" >> $logF_;
  echo -e "\nCreating the $logF_ file...    \ncheck for errors...\n";
  cat $logF_;
  echo -e "\n10 seconds pause...\n\n\n";
  sleep 10;
}



function get_swapfile_name() {
    local f=$(swapon --show=NAME --noheadings | grep -E '\.(img|file)$' | head -n1)
    [[ -z "$f" && -f /swap.img ]] && f="/swap.img"
    [[ -z "$f" && -f /swapfile ]] && f="/swapfile"
    [[ -n "$f" ]] && echo "$f" || echo ""
}



# -  - #
# - createzRam_ - #
function createzRam_(){
  local zRamCnf_=/etc/systemd/zram-generator.conf \
        swapFile_;

  clear;
  echo -e "\n\n=== Removing swap.img and configuring zram... ===\n";

  source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)
  distroVersion_;
  swapFile_=$(get_swapfile_name);
  
  # 1. Check if swapFile_ exists
  if [ -f "$swapFile_" ]; then
    echo "  → Found $swapFile_"
    echo "  → Disabling swap file..."
    sudo swapoff "$swapFile_" 2>/dev/null || true
    echo "  → Removing $swapFile_ from /etc/fstab..."
    sudo sed -i "\|$swapFile_|d" /etc/fstab
    echo "  → Deleting $swapFile_..."
    sudo rm -f "$swapFile_"
    echo "  → $(basename "$swapFile_") removed successfully."  # Shows just the filename
  else
    echo "  → No swap file found. Skipping."
  fi

  # 5. Create zram
  echo -e "\n\n=== Installing zram... ===\n";

  # Distro-specific package names for zram-generator
  # Uses Opt variable from distroVersion_()
  local lPrograms1_
  case $Opt in
    1 | 4 | 5 )
      # - ubuntu, debian, linuxmint, zorin - #
      lPrograms1_="systemd-zram-generator";;
    2 )
      # - arch - #
      lPrograms1_="zram-generator";;
    3 )
      # - fedora - #
      lPrograms1_="zram-generator";;
    * )
      # - Fallback - let sPackages_ try its best - #
      lPrograms1_="zram-generator";;
  esac
  sPackages_ "$lPrograms1_";

    echo "  → Creating $zRamCnf_ ..."
    sudo tee "$zRamCnf_" > /dev/null << ZRAMEOF
[zram0]
zram-size = ram / 2
compression-algorithm = zstd
swap-priority = 100
fs-type = swap
ZRAMEOF
    echo -e "\n\n$zRamCnf_ details:\n"
    cat "$zRamCnf_"
    sudo systemctl daemon-reload
    sudo systemctl start /dev/zram0
    sleep 4;
    sudo systemctl status /dev/zram0 --no-pager;

  echo -e "\nChecking zram status...\n"
  if command -v zramctl &> /dev/null; then
    zramctl
  else
    echo "zramctl not found - install util-linux if needed"
  fi

  free -h

  # Verify swap is active
  echo -e "\nVerifying swap status..."
  if swapon --show 2>/dev/null | grep -q zram; then
    echo "✓ zram swap is active and ready"
  else
    echo "⚠ Warning: zram swap not found. You may need to reboot."
  fi

  echo -e "\n\nZram was installed successfully...\n";
}



# -  - #
# - sPackages_ - #
function sPackages_(){
  local lPacks_=$1 sCmd_="" valid_pkgs=();
<<'comment'
  echo -e "\nDistro: $Opt"
  echo -e "I am here...\nSleeping 10 seconds.\n"
  sleep 10;
comment
  # -  - #
  # - $Opt = distroVersion_ - #
  if (( $EUID != 0 )); then sCmd_="sudo"; fi;
  case $Opt in
    1 | 5 )
      # - Debian / Ubuntu / Mint - #
      for pkg in $lPacks_; do
          if apt-cache show "$pkg" &>/dev/null; then
              valid_pkgs+=("$pkg");
          else
              echo -e "$pkg" >> "$logF_";
          fi;
      done
      if [ ${#valid_pkgs[@]} -gt 0 ]; then
          $sCmd_ apt install -y "${valid_pkgs[@]}"; fi;
      ;;
    2 )
      # - Arch - #
      for pkg in $lPacks_; do
          if pacman -Si "$pkg" &>/dev/null; then
              valid_pkgs+=("$pkg");
          else
              echo -e "$pkg" >> $logF_;
          fi;
      done
      if [ ${#valid_pkgs[@]} -gt 0 ]; then
          $sCmd_ pacman -S "${valid_pkgs[@]}" --noconfirm --needed; fi;
      ;;
    3 )
      # - Fedora - #
      for pkg in $lPacks_; do
          if dnf list available "$pkg" &>/dev/null; then
              valid_pkgs+=("$pkg");
          else
              echo -e "$pkg" >> "$logF_";
          fi;
      done
      if [[ ${#valid_pkgs[@]} -gt 0 ]]; then
          $sCmd_ dnf install -y "${valid_pkgs[@]}"; fi;
      ;;
    4 )
      # - Zorin - #
      for pkg in $lPacks_; do
          if apt-cache show "$pkg" &>/dev/null; then
              valid_pkgs+=("$pkg");
          else
              echo -e "$pkg" >> "$logF_";
          fi;
      done
      if [ ${#valid_pkgs[@]} -gt 0 ]; then
          $sCmd_ apt install -y "${valid_pkgs[@]}"; fi;
      ;;
  esac
}



# -  - #
# - xorg_ - #
function xorg_(){
  echo -e "\nInstalling xOrg server...\n";

  lPrograms1_="xorg xorg-server";
  sPackages_ "$lPrograms1_";

  echo -e "\nxOrg server was installed successfully...\n\n";
  sleep 10;
}



# -  - #
# - wayland_ - #
function wayland_(){
  echo -e "\nInstalling wayland server...\n";

  lPrograms1_="wayland xorg-xwayland xorg-xlsclients";
  sPackages_ "$lPrograms1_";
  sudo pacman -S glfw-wayland --noconfirm --needed;
  echo -e "\nWayland server was installed successfully...\n\n";
  sleep 10;
}



# -  - #
# - gdm_ - #
function gdm_(){
  local sS1_='gdm' sS2_='';

  # -  - #
  # - gdm (Gnome) - #

  sS2_=$( echo $(pacman -Qqe | grep "$sS1_" ) | awk '{print $1;}');
  if [ "$sS1_" == "$sS2_" ]; then echo "Gdm login manager already installed..."; sleep 5; return; fi;

  echo -e "\nInstalling Gdm login manager...\n";

  lPrograms1_="gdm";
  sPackages_ "$lPrograms1_";

  sudo systemctl enable gdm;
  echo -e "\nGdm login manager was installed successfully...\n\n";
  sleep 10;
}



# -  - #
# - lightdm_ - #
function lightdm_(){
  local sS1_='lightdm' sS2_='';

  # -  - #
  # - lightdm (Budgie, Cinnamon, Deepin, Mate, OpenBox, Xfce & XMonad) - #

  sS2_=$( echo $(pacman -Qqe | grep "$sS1_" ) | awk '{print $1;}');
  if [ "$sS1_" == "$sS2_" ]; then echo "lightdm login manager already installed..."; sleep 5; return; fi;

  echo -e "\nInstalling lightdm login manager...\n";

<<'comment'
  light-locker
  sudo pacman -Rns light-locker --noconfirm;
comment

  lPrograms1_="lightdm lightdm-gtk-greeter lightdm-gtk-greeter-settings accountsservice";
  sPackages_ "$lPrograms1_";

  sudo systemctl enable lightdm;
  echo -e "\nLightDM login manager was installed successfully...\n\n";
  sleep 10;
}



# -  - #
# - sddm_ - #
function sddm_(){
  local sS1_='sddm' sS2_='';

  # -  - #
  # - sddm (PlasmaKDE) - #

  sS2_=$( echo $(pacman -Qqe | grep "$sS1_" ) | awk '{print $1;}');
  if [ "$sS1_" == "$sS2_" ]; then echo "Sddm login manager already installed..."; sleep 5; return; fi;

  echo -e "\nInstalling Sddm login manager...";

  lPrograms1_="sddm";
  sPackages_ "$lPrograms1_";

  sudo systemctl enable sddm;
  echo -e "\nSddm login manager was installed successfully...\n\n";
  sleep 10;
}



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

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

  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 "\nWallpapers were configured successfully...\n\n\n";
  sleep 5;
}



# -  - #
# - ubuntuIconsInstall_ - #
function ubuntuIconsInstall_(){
  local wI_='https://www.education.isdevelopment.us/Ubuntu.Ins/Software.Ins/Ubuntu-Icons/' \
        uiF_='archdroid-icon-theme.sh';
  local sIc_='Ubuntu icon files' \
        dDwn_=~/Downloads/$uiF_;
  echo -e "\n\n\n\nInstalling $sIc_...\n";

  curl -o $dDwn_ $wI_$uiF_;
  chmod +x $dDwn_;
  ~/./Downloads/$uiF_;
  gsettings set org.gnome.desktop.interface icon-theme 'Archdroid-Blue';

  echo -e "\n$sIc_ were installed successfully...\n\n";
  if [ "$sPause_" == "1" ]; then
    sleep $nS_; fi;
}



# -  - #
# - Lightdm_GTK_Greeter_ - #
function Lightdm_GTK_Greeter_(){
  local lightdmF_=/etc/lightdm/lightdm-gtk-greeter.conf \
        xfceF_=/home/$USER/.config/xfce4/xfconf/xfce-perchannel-xml/xfce4-desktop.xml \
        monitor_='';

  monitor_=$(xrandr --listactivemonitors | grep '\*' | awk '{print $NF}');
  if [[ -z "$monitor_" ]]; then
    monitor_=$(xrandr --listactivemonitors | awk 'NR==2{print $NF}');
  fi;


<<'comment'
        # Try to get primary monitor first, fall back to first monitor if no primary exists
        monitor_=$(xrandr --listactivemonitors | grep '\*' | awk '{print $NF}');
        if [[ -z "$monitor_" ]]; then
          monitor_=$(xrandr --listactivemonitors | awk 'NR==2{print $NF}')
        fi

        monitor_=$(xrandr --listactivemonitors | awk 'END{print $NF}');
comment

  # -  - #
  # - Documentation - #
  # https://wiki.archlinux.org/title/Xfce
  local oF_='Bonsai-Plant.png';
  
  echo -e "\nConfiguring $lightdmF_...";

  # -  - #
  # - Change to new background - #
  sed -i "s/$oF_/$bGpicture/g" $xfceF_;

  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_;
  sudo sed -i "$ a background = $bGround_" $lightdmF_;
  sudo sed -i "$ a reader = xrandr --output $monitor_ --primary --mode 1920x1080" $lightdmF_;
  sudo sed -i '$ a a11y-states = +reader' $lightdmF_;
  
  echo -e "\n$lightdmF_ was configured successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - FirefoxConfiguration_ - #
function FirefoxConfiguration_(){
  local sPhase_=$1;
  local sWs_=/Arch.Ins/Software.Ins/ \
        sFc_=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_$sFc_; fi;

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

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

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



# -  - #
# - dotConfig_OpenBox_ - #
function dotConfig_OpenBox_(){
  local sPhase_=$1;
  local wF_=/Arch.Ins/Software.Ins/ \
        sFd_=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_$sFd_; fi;

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

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


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

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



# -  - #
# - ConfiguringSystem_ - #
function ConfiguringSystem_(){
  local sPhase_=$1 \
        bHis_=~/.bash_history;

  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
  case $Desktop_ in
    ''|*[!0-9]*)
      echo -e "\nIts not a number...";
      ;;
    1)
      if [ "$sPhase_" == "1" ]; then
        XfceDesktopProgramsShortcuts_; fi;
      dotConfig_Xfce_ $sPhase_;
      ;;
    2)
      dotConfig_Cinnamon_ $sPhase_;
      ;;
    3)
      dotConfig_PlasmaKDE_ $sPhase_;
      ;;
    4)
      dotConfig_Gnome_ $sPhase_;
      ;;
    7)
      dotConfig_OpenBox_ $sPhase_;
      ;;
    *)
      echo "Option no valid: " $Desktop_;
      ;;
  esac

  FirefoxConfiguration_ $sPhase_;

  if [[ "$Desktop_" != "1" ]] && [[ "$Desktop_" != "3" ]] && [[ "$Desktop_" != "4" ]]; then
    if [ "$sPhase_" == "2" ]; then
      Lightdm_GTK_Greeter_;
    fi;
  fi;

  history -c && rm -rf $bHis_;
}



# -  - #
# - lVersion_ - #
function lVersion_(){
  local sVer_='';
  if [[ -f "$aDesktopConf_" ]]; then
    sVer_=$( echo $(cat $aDesktopConf_ | grep version | awk '{print $5;}' ) );
  fi;
  echo $sVer_;
}



# -  - #
# - networkName_ - #
function networkName_(){
<<'comment'
  echo $( ifconfig -a | sed 's/[ \t].*//;/^$/d' | grep -Ei 'enp|eth' );
  echo $( ifconfig | grep "enp" | awk '{print $1}' );
  ip a | grep -Ei 'enp|eth'
  ip a | grep -Ei 'enp|eth|network|ethernet'
  echo $( ip a | grep "enp" | awk '{print $2}' );
comment
  echo $( basename -a /sys/class/net/*  | grep -Ei 'enp|ens|eth' )
}



# -  - #
# - virtualManager_ - #
function virtualManager_(){
  local sV_=$( grep -q "^flags.*hypervisor" /proc/cpuinfo && echo "Yes" );
  if [ "$sV_" != "Yes" ]; then sV_='No'; fi;
  echo $sV_;
}



# -  - #
# - checkYay_ - Check if yay is installed, install if missing - #
function checkYay_() {
    if command -v yay &>/dev/null; then
        return 0
    else
        echo -e "\n⚠️  yay not found!"
        echo "   Installing yay from AUR..."
        
        # Install yay
        sudo pacman -S --needed git base-devel --noconfirm
        git clone https://aur.archlinux.org/yay.git /tmp/yay
        cd /tmp/yay
        makepkg -si --noconfirm
        cd ~
        rm -rf /tmp/yay
        
        if command -v yay &>/dev/null; then
            echo -e "\n✅ yay installed successfully!"
            return 0
        else
            echo -e "\n❌ Failed to install yay!"
            return 1
        fi
    fi
}



# -  - #
# - Arch - #
# - aGnomeDesktop_ - #
function aGnomeDesktop_(){
  echo -e "\n\n\nInstalling Gnome Desktop...\n\n";

  lPrograms1_="adwaita-icon-theme fwupd gnome gnome-browser-connector \
               gnome-backgrounds gnome-control-center gnome-menus \
               gnome-multi-writer gnome-nettool gnome-shell gnome-system-monitor \
               gnome-terminal gnome-tweaks gnome-usage nautilus nemo-fileroller";
  sPackages_ "$lPrograms1_";

  sudo pacman -S gnome-extra --noconfirm --needed;
  sudo pacman -S gnome-shell-extensions --noconfirm --needed;

  echo -e "\n\nExtension manager will be installed...\n";
  sudo flatpak install flathub com.mattjakeman.ExtensionManager -y;

  # Check if yay is installed before using it

  if checkYay_; then
    yay -S gnome-shell-extension-blur-my-shell --noconfirm --needed;
    yay -S gnome-shell-extension-dash-to-dock --noconfirm --needed;
    yay -S gnome-shell-extension-user-themes --noconfirm --needed;
    #yay -S gnome-shell-extension-just-perfection --noconfirm --needed;
    echo -e "\nCheck for errors...\n";
  else
    echo -e "\n⚠️  yay not found! Skipping AUR extensions."
    echo "   To install yay: git clone https://aur.archlinux.org/yay.git && cd yay && makepkg -si"
  fi

<<comment
  # -  - #
  # - Show programs list available in flathub repository - #
  flatpak remote-ls flathub;
comment

  echo -e "\n\n\nGnome desktop was installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - Gnome Desktop - #
# - gnomeDesktopSoftware_ - #
function gnomeDesktopSoftware_(){
  local sNDS_='Gnome desktop software' \
        eBmyS_=https://www.education.isdevelopment.us/Ubuntu.Ins/blur-my-shell-master.zip \
        eJP_=https://www.education.isdevelopment.us/Ubuntu.Ins/just-perfection-main.zip;
  local eDtoD_=https://www.education.isdevelopment.us/Ubuntu.Ins/dash-to-dockmicxgx.gmail.com.v103.shell-extension.zip \
        fDtoD_=~/Downloads/fDtoD.zip \
        sCmd_='';
  echo -e "\n\n\nInstalling $sNDS_...\n\n";

  lPrograms1_="gnome-browser-connector gnome-multi-writer gnome-software-plugin-flatpak \
               gnome-system-monitor gnome-terminal gnome-themes-extra gnome-tweaks gnome-usage nautilus \
               nemo-fileroller";
  sPackages_ "$lPrograms1_";
  sleep 10;

<<'comment'
  sudo apt install chrome-gnome-shell -y;
  sudo apt install gnome-browser-connector -y;
  sudo apt install gnome-shell -y;
  sudo apt install gnome-shell-extension-manager -y
  yay -S gnome-shell-extension-just-perfection --noconfirm --needed;
comment

  echo -e "\n\nInstalling extension manager...\n";
  sudo flatpak install flathub com.mattjakeman.ExtensionManager -y;
  sleep 10;

  echo -e "\n\nInstalling gnome-shell extensions...\n";
  sudo $sCmd_ gnome-shell-extensions;
  sudo $sCmd_ gnome-shell-extension-prefs;
  sleep 10;

  # -  - #
  # - User theme - #
  echo -e "\n\nInstalling user theme extension...\n";

  sudo $sCmd_ gnome-shell-extension-user-theme;
  gnome-extensions list;
  echo -e "\n\n...";

<<'comment'
  gnome-extensions install another-window-session-manager@gmail.com;
  gnome-extensions enable another-window-session-manager@nlpsuge.github.com;

  vim ~/.config/autostart/_awsm-restore-previous-session.desktop;
comment

  gnome-extensions enable user-theme@gnome-shell-extensions.gcampax.github.com;
  gnome-extensions enable ubuntu-dock@ubuntu.com
  sleep 10;

  # -  - #
  # - DashToDock - #
  echo -e "\n\nInstalling dash to dock extension...\n";

  curl -o $fDtoD_ $eDtoD_;
  gnome-extensions install --force $fDtoD_;
  rm -rf $fDtoD_;

  gnome-extensions list --user;
  gnome-extensions enable dash-to-dock@micxgx.gmail.com;
  echo -e "\nDash to dock extension was installed,\nCheck for errors...\n";

  # -  - #
  # - Other configurations - #
  gsettings set org.gnome.desktop.interface gtk-theme 'Arc-Dark';
  gsettings set org.gnome.desktop.session idle-delay 0;
  gsettings set org.gnome.desktop.screensaver lock-enabled false;
  gsettings set org.gnome.desktop.lockdown disable-lock-screen true;
  gsettings set org.gnome.desktop.interface color-scheme prefer-dark;
  gsettings set org.gnome.desktop.wm.preferences button-layout ":minimize,maximize,close";

  # -  - #
  # - Reorganize Show Apps on the screen - #
  gsettings reset org.gnome.shell app-picker-layout;

  xset s off;

  sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target;

  echo -e "\n\nUbuntu gnome extensions were installed,\nCheck for errors...\n";
  sleep 10;

<<'comment'

  # -  - #
  # - Show values - #
  gsettings set org.gnome.desktop.session idle-delay;
  gsettings set org.gnome.desktop.screensaver lock-enabled;

  gnome-extensions install --force $eDtoD_;

  eDtoD_=https://www.education.isdevelopment.us/Ubuntu.Ins/dash-to-dockmicxgx.gmail.com.v103.shell-extension.zip \
  fDtoD_=~/Downloads/fDtoD.zip;

  rm -rf $fDtoD_; curl -o $fDtoD_ $eDtoD_;
  gnome-extensions install --force $fDtoD_;
  rm -rf $fDtoD_;

  gnome-extensions list --user;
  gnome-extensions enable dash-to-dock@micxgx.gmail.com;

  # -  - #
  # - Documentation - #
  https://ubuntuhandbook.org/index.php/2025/11/manage-gnome-shell-extensions-from-command-line/

  # -  - #
  # - Manage extensions - #
  gnome-extensions list;

  # - show installed extensions - #
  gnome-extensions list --user;
  gnome-extensions list --user --enabled;

  (Press tab twice)
  gsettings list-recursively org.gnome.shell.extensions.

org.gnome.shell.extensions.apps-menu                        org.gnome.shell.extensions.blur-my-shell.dash-to-panel      org.gnome.shell.extensions.dash-to-dock
org.gnome.shell.extensions.auto-move-windows                org.gnome.shell.extensions.blur-my-shell.hidetopbar         org.gnome.shell.extensions.native-window-placement
org.gnome.shell.extensions.blur-my-shell                    org.gnome.shell.extensions.blur-my-shell.lockscreen         org.gnome.shell.extensions.screenshot-window-sizer
org.gnome.shell.extensions.blur-my-shell.appfolder          org.gnome.shell.extensions.blur-my-shell.overview           org.gnome.shell.extensions.system-monitor
org.gnome.shell.extensions.blur-my-shell.applications       org.gnome.shell.extensions.blur-my-shell.panel              org.gnome.shell.extensions.user-theme
org.gnome.shell.extensions.blur-my-shell.coverflow-alt-tab  org.gnome.shell.extensions.blur-my-shell.screenshot         org.gnome.shell.extensions.window-list
org.gnome.shell.extensions.blur-my-shell.dash-to-dock       org.gnome.shell.extensions.blur-my-shell.window-list        org.gnome.shell.extensions.workspace-indicator

  gsettings list-recursively org.gnome.shell.extensions.dash-to-dock;
  gsettings set org.gnome.desktop.interface;

  gsettings list-recursively org.gnome.desktop.interface;
  gsettings set org.gnome.desktop.interface gtk-theme 'Arc-Dark';
  gsettings set org.gnome.desktop.interface gtk-theme 'Yaru-blue';
  gsettings set org.gnome.desktop.interface icon-theme 'Archdroid-Blue';

  bGround_=/usr/share/backgrounds/Various/Garage.jpg;
  gsettings set org.gnome.desktop.background picture-uri      file:///$bGround_;
  gsettings set org.gnome.desktop.background picture-uri-dark file:///$bGround_;
  gsettings set org.gnome.shell.extensions.user-theme name "Obsidian-flow-purple-dark";
  gsettings set org.gnome.shell.extensions.user-theme name "Adwaita";

  # -  - #
  # - Documentation - #
  https://discussion.fedoraproject.org/t/change-scaling-resolution-of-primary-monitor-from-bash-terminal/76778/11

  gsettings set org.gnome.mutter experimental-features "['scale-monitor-framebuffer']"
  gsettings set org.gnome.desktop.interface text-scaling-factor 1.2

  # -  - #
  # - You can get the 200% scale UI - #
  gsettings set org.gnome.desktop.interface scaling-factor 2;

  # -  - #
  # - gsettings - #
  https://commandmasters.com/commands/gsettings-linux/
  gsettings set org.example.schema example-key value

  # -  - #
  # - gsettings (get value) - #
  gsettings get org.example.schema example-key

  # -  - #
  # - gsettings (Reset value - Remove value) - #
  gsettings reset org.example.schema example-key

  # -  - #
  # - gsettings (Show values) - #
  gsettings list-recursively org.example.schema

  # -  - #
  # - gsettings (Allowed values) - #
  gsettings range org.example.schema example-key

  # -  - #
  # - gsettings (Describe values) - #

  gsettings set org.gnome.mutter experimental-features "['x11-randr-fractional-scaling']"

  gsettings set org.gnome.desktop.interface text-scaling-factor 2.0;

  chromium --high-dpi-support=1 --force-device-scale-factor=1.5;

  dbus-launch gsettings set org.gnome.desktop.background draw-background true

  # -  - #
  # - Tab to show desktos - #
  gsettings list-recursively org.gnome.desktop.    # (tab tab) - Show desktops

  # -  - #
  # - Enter to show interfaces values - #
  gsettings list-recursively org.gnome.desktop.interface    # (Enter) - Show interfece values

  # -  - #
  # - Enter to show preferences values - #
  gsettings list-recursively org.gnome.desktop.wm.preferences     # (Enter) - Show preferences

  # -  - #
  # - Enter to show peripherals values - #
  gsettings list-recursively org.gnome.desktop.peripherals     # (Enter) - Show peripherals values
  gsettings list-recursively org.gnome.desktop.peripherals.    # (tab tab) - Show peripherals

  # -  - #
  # - Other configurations - #
  gsettings list-recursively org.gnome.shell.extensions.dash-to-dock;

  gsettings set org.gnome.shell.extensions.dash-to-dock always-center-icons false;
  gsettings set org.gnome.shell.extensions.dash-to-dock always-center-icons true;
  gsettings set org.gnome.shell.extensions.dash-to-dock show-trash true;
  gsettings set org.gnome.shell.extensions.dash-to-dock extend-height false;
  gsettings set org.gnome.shell.extensions.dash-to-dock dock-position TOP;
  gsettings set org.gnome.shell.extensions.dash-to-dock dock-position BOTTOM;
  gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode FIXED;
  gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode DEFAULT;
  gsettings set org.gnome.shell.extensions.dash-to-dock transparency-mode "FULL";
  gsettings set org.gnome.shell.extensions.dash-to-dock unity-backlit-items true;

  gsettings set org.gnome.shell.extensions.dash-to-dock background-opacity 0.0;
  gsettings set org.gnome.shell.extensions.dash-to-dock background-opacity 0.9;
  gsettings reset org.gnome.shell.extensions.dash-to-dock background-opacity;

  gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 32;
  gsettings set org.gnome.shell.extensions.dash-to-dock dash-max-icon-size 48;    # - Original - #
  gsettings reset org.gnome.shell.extensions.dash-to-dock dash-max-icon-size;    # - Get back to original - #

  # -  - #
  # - Blur my shell - #
  gnome-extensions install --force $eBmyS_;
  gnome-extensions list --user;
  gnome-extensions enable user-theme@gnome-shell-extensions.gcampax.github.com;

  # -  - #
  # - JustPerfection - #
  gnome-extensions install --force $eJP_;
  gnome-extensions list;
  gnome-extensions enable dash-to-dock@micxgx.gmail.com;

  # -  - #
  # - Show programs list available in flathub repository - #
  flatpak remote-ls flathub;

comment

  echo -e "\n\n\n$sNDS_ was installed successfully...\n\n\n";
  #cd $Dir_; 
  sleep 10;
}



# -  - #
# - myPersonalCrontab_ - #
function myPersonalCrontab_(){
  local myCrontab_=~/Downloads/myCrontab.sh \
        myCrontabCmd_=~/Downloads/./myCrontab.sh \
        dotProfile_='' \
        sOrigen_=$1 \
        myCmd2_='';

  #source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)
  distroVersion_;

  myCmd2_=$( echo "$myCrontabCmd_" | sed 's/\//\\\//g' );
  rm -rf $myCrontab_;

  case $Opt in
    1)
      # - Ubuntu - #
      dotProfile_=~/.profile;
      myPersonalCrontab_Build01_ "$myCrontab_" "$dotProfile_" "$sOrigen_";
      ;;
    2)
      # - Arch - #
      dotProfile_=~/.bash_profile;
      myPersonalCrontab_Build02_ "$myCrontab_" "$dotProfile_" "$myCmd2_";
      ;;
    3)
      # - Fedora - #
      dotProfile_=~/.profile;
      ;;
  esac

  chmod +x $myCrontab_;

  # -  - #
  # - create .bash_profile if not exists - #
  if [[ ! -f "$dotProfile_" ]]; then
    touch "$dotProfile_"; fi;

  # -  - #
  # - Add "sh ./Downloads/myCrontab.sh" to .bash_profile - #
  sed -i "/$myCmd2_/d" $dotProfile_;
  echo -e $myCrontabCmd_ >> $dotProfile_
}



# -  - #
# - myPersonalCrontab_Build01_ - #
function myPersonalCrontab_Build01_(){
  local myCrontab_=$1 \
        dotProfile_=$2 \
        sOrigen_=$3 Org_='';

  rm -f "$myCrontab_"
cat <<EOT >> $myCrontab_;
#!/bin/bash

# -  - #
# - Loading functions.sh - #
source <(curl -s https://www.education.isdevelopment.us/Functions/Functions.sh)

Org_=$sOrigen_;

case "\$Org_" in
  1)
    # -  - #
    # - Enable Dash to Dock extension - #
    uDashToDockFinalConfiguration_;
    ;;
  2)
    # -  - #
    Test_='';
    ;;
esac

sed -i "/$sOrigen_/d" $dotProfile_;
rm -rf $myCrontab_;
EOT
}



# -  - #
# - myPersonalCrontab_Build02_ - #
function myPersonalCrontab_Build02_(){
  local myCrontab_="$1" \
        dotProfile_="$2" \
        myCmd2_="$3" \
        lightdmF_=/etc/lightdm/lightdm-gtk-greeter.conf \
        myLightdmF_=~/Downloads/myLightdm.conf;


echo -e "\n\nReconfiguring screen resolution...";


  # -  - #
  # - Ensure clean file creation by removing any old leftovers first - #
  rm -rf "$myCrontab_"

cat <<EOT >> "$myCrontab_"
#!/bin/bash

# -  - #
# - Pause - #
echo -e "\n\nWait for desktop to fully initialize.\n";
echo -e "\n\n15 seconds pause...\n";
sleep 10

lightdmF_=/etc/lightdm/lightdm-gtk-greeter.conf;
myLightdmF_=~/Downloads/myLightdm.conf;
myDisplay_=~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml;

# -  - #
# - Capture monitor resolution - #
monitor_=\$(xrandr --listactivemonitors | awk 'END{print \$NF}')
resolution_=\$(sed 's/version="1.1"/version="1.0"/' \$myDisplay_ | xmllint --xpath 'string(//property[@name="Default"]//property[@name="Resolution"]/@value)' -)

# Only proceed if resolution was captured
if [[ -z "\$resolution_" ]]; then
    echo "No resolution detected - skipping"
    exit 1
fi


cp -v \$lightdmF_ \$myLightdmF_;
echo -e "\n\n\$myLightdmF_ Old configuration...\n";
cat \$myLightdmF_;

# -  - #
# - Set screen resolution in my lightdm file @ ~/Documents/myLightdm.conf - #
sed -i "s|^reader = xrandr --output.*|reader = xrandr --output \$monitor_ --primary --mode \$resolution_|" "\$myLightdmF_"

echo -e "\n\n\$myLightdmF_ New configuration...\n";
cat \$myLightdmF_;


sRes_=\$( cat \$lightdmF_ | grep reader | awk '{print \$8}' );
echo -e "\n      New screen resolution: \$resolution_";
echo -e   " Original screen resolution: \$sRes_\n\n";


if [[ "\$sRes_" != "\$resolution_" ]]; then
  if sudo cp -v \$myLightdmF_ \$lightdmF_; then
    rm -rf $myLightdmF_;
    sed -i "/$myCmd2_/d" "$dotProfile_"
    rm -rf $myCrontab_
  else
    echo "ERROR: Failed to copy LightDM config" >&2
  fi
fi;



# -  - #
# - Setting dark theme for external Apps - #
gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark';



<<'comment'
  sudo cp -v /home/is_derayo/Downloads/myLightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf;
  sudo mv /home/is_derayo/Downloads/myLightdm.conf /etc/lightdm/lightdm-gtk-greeter.conf;
  rm -rf /home/is_derayo/Downloads/myLightdm.conf;


  # -  - #
  # - Delete "sh ./Downloads/myCrontab.sh" from .bash_profile - #
  sed -i "/\/home\/is_derayo\/Downloads\/.\/myCrontab.sh/d" "/home/is_derayo/.bash_profile"
  rm -rf /home/is_derayo/Downloads/myCrontab.sh;


  cat ~/.bash_profile;
    #
  # ~/.bash_profile
  #

  [[ -f ~/.bashrc ]] && . ~/.bashrc
  /home/is_derayo/Downloads/./myCrontab.sh
comment

EOT



<<'comment'
  lightdmF_=/etc/lightdm/lightdm-gtk-greeter.conf;
  myLightdmF_=~/Downloads/myLightdm.conf;
  myDisplay_=~/.config/xfce4/xfconf/xfce-perchannel-xml/displays.xml;

  monitor_=$(xrandr --listactivemonitors | awk 'END{print $NF}');
  resolution_=$(sed 's/version="1.1"/version="1.0"/' $myDisplay_ | xmllint --xpath 'string(//property[@name="Default"]//property[@name="Resolution"]/@value)' -)

  cp -v $lightdmF_ $myLightdmF_;
  echo -e "\n\n$myLightdmF_ old configuration\n";
  cat $myLightdmF_;

  # -  - #
  # - Set screen resolution in my lightdm file @ ~/Documents/myLightdm.conf - #
  sed -i "s|^reader = xrandr --output.*|reader = xrandr --output $monitor_ --primary --mode $resolution_|" "$myLightdmF_"

  echo -e "\n\n$myLightdmF_ new configuration\n";
  cat $myLightdmF_;

  sRes_=$( cat $lightdmF_ | grep reader | awk '{print $8}' );
  echo -e "\n      New screen resolution: $resolution_";
  echo -e   " Original screen resolution: $sRes_\n\n";

  gsettings set org.gnome.desktop.interface color-scheme 'prefer-dark';
comment

  chmod +x "$myCrontab_"
  echo -e "\nScreen resolution was configured successfully.";
  echo -e "\nIn order for changes to take effect the system has to shutdown...";
  sleep 10;
}



# -  - #
# - Ubuntu - #
# - uDashToDockFinalConfiguration_ - #
function uDashToDockFinalConfiguration_(){
  local sDdc_='dash to dock extension' \
        eDtoD_=https://www.education.isdevelopment.us/Ubuntu.Ins/dash-to-dockmicxgx.gmail.com.v103.shell-extension.zip \
        fDtoD_=~/Downloads/fDtoD.zip;
  echo -e "\n\n\nConfiguring $sDdc_...\n\n";

  rm -rf $fDtoD_; curl -o $fDtoD_ $eDtoD_;
  gnome-extensions install --force $fDtoD_;
  rm -rf $fDtoD_;

  gnome-extensions list --user;
  gnome-extensions enable dash-to-dock@micxgx.gmail.com;
  gnome-extensions enable user-theme@gnome-shell-extensions.gcampax.github.com;

  echo -e "\n\n\n$sDdc_ was configured successfully...\n\n\n";
  sleep 10;
}


<<'comment'
# -  - #
# - lightdmResolution_ - #
function lightdmResolution_(){
  local lightdmF_='/etc/lightdm/lightdm-gtk-greeter.conf' \
        monitor_ \
        resolution_;
  
  # 1. Install xrandr FIRST so the commands below actually work
  sudo pacman -S xorg-xrandr --noconfirm --needed;
#<<'comment'
  xrandr --current | grep '*';
  xrandr --current | grep '*' | awk '{print $1}';
#comment
  # 2. Extract the monitor and resolution details
  monitor_=$(xrandr --listactivemonitors | awk 'END{print $NF}');
  resolution_=$(xrandr | grep -w connected | awk '{for(i=1;i<=NF;i++) if($i ~ /[0-9]+x[0-9]+\+/) print $i}' | cut -d+ -f1);
  
  # 3. Hijack the greeter's reader option to force the correct resolution
  sudo sed -i "s|^reader = xrandr --output.*|reader = xrandr --output $monitor_ --primary --mode $resolution_|" "$lightdmF_";
  sudo shutdown now;
}
comment



# -  - #
# - eTilingShell_ - #
function eTilingShell_(){
  local eN_='tilingshell@ferrarodomenico.com' \
        oCmd_='gnome-extensions enable ';
  local nTs_=$eN_'.zip' \
        sT_=~/Tmp.txt;
  local sTs_='Tiling shell extension' \
        wTsf_=https://www.education.isdevelopment.us/Ubuntu.Ins/$nTs_ \
        oTsf_=~/Downloads/$nTs_ \
        dTsf_=~/.local/share/gnome-shell/extensions/ \
        dotProfile_='' \
        sCb_='tilingshell\@ferrarodomenico.com;';
  local myCa_=$oCmd_$eN_';' \
        myCb_='';

  echo -e "\n\nInstalling $sTs_...\n";

  curl -o $oTsf_ $wTsf_;
  unzip $oTsf_ -d $dTsf_;
  rm -rf $oTsf_;
  gnome-extensions enable $eN_;

  case $Opt in
    1)
      # - Ubuntu - #
      dotProfile_=~/.profile;
      ;;
    2)
      # - Arch - #
      dotProfile_=~/.bash_profile;
      ;;
    3)
      # - Fedora - #
      dotProfile_=~/.profile;
      ;;
  esac

  myCb_="head -n -2 $dotProfile_ > $sT_ && mv $sT_ $dotProfile_;";

  if [[ ! -f "$dotProfile_" ]]; then
    touch "$dotProfile_"; fi;

  echo -e $myCa_ >> $dotProfile_;
  echo -e $myCb_ >> $dotProfile_;

  echo -e "\n$sTs_ was installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - obsidianFlowShellTheme_ - #
function obsidianFlowShellTheme_(){
  local dThe_=~/.themes \
        dDow_=~/Downloads \
        dConf_=$uWServer_/Arch.Ins/Software.Ins/saved_settings.dconf;
  local dObs_=$dDow_/Obsidian-flow-shell-theme;
  echo -e "\nInstalling obsidian flow shell theme...\n";

  mkdir -p $dThe_;
  cd $dDow_; rm -rf $dObs_;
  git clone https://github.com/JustDeax/Obsidian-flow-shell-theme.git

  cd $dObs_;

  case $Opt in
    1)
      # - Ubuntu - #
      sP_='python3';
      ;;
    2)
      # - Arch - #
      sP_='python';
      ;;
    3)
      # - Fedora - #
      sP_='python';
      ;;
  esac

  eval "$sP_" install.py -a;
  eval "$sP_" install.py -a --filled;

  sudo $sP_ install.py --gdm --blue --filled \
                       --gdm-image $bGround_ \
                       --gdm-blur=40 --gdm-darken=30;
  
  gsettings set org.gnome.desktop.background picture-uri      file:///$bGround_;
  gsettings set org.gnome.desktop.background picture-uri-dark file:///$bGround_;
  gsettings set org.gnome.shell.extensions.user-theme name "Obsidian-flow-purple-dark";

  cd $Dir_;
  rm -rf $dObs_;
  echo -e "\nObsidian flow shell theme was installed successfully...\n\n\n";
  sleep 10;
}



# -  - #
# - xrandrConfiguration_ - #
function xrandrConfiguration_(){
  local sScreen_=$( xrandr --query | grep "connected" | awk '{print $1}' ) \
        sRes_=2560x1080;
  xrandr --output $sScreen_ --mode $sRes_;
}



# -  - #
# - screenResolution_ - #
function screenResolution_(){
  local fMonitors_=~/.config/monitors.xml;
  local fMb_=$fMonitors_.Backup \
        vMonitor_=$( xrandr --query | grep "connected" | awk '{print $1}' ) \
        xW_=2560 yH_=1080;
  rm -rf $fMb_;
  mv $fMonitors_ $fMonitors_.Backup;
cat <<EOT >> $fMonitors_;
<monitors version="2">
  <configuration>
    <layoutmode>logical</layoutmode>
    <logicalmonitor>
      <x>0</x>
      <y>0</y>
      <scale>1</scale>
      <primary>yes</primary>
      <monitor>
        <monitorspec>
          <connector>$vMonitor_</connector>
          <vendor>RHT</vendor>
          <product>QEMU Monitor</product>
          <serial>0x00000000</serial>
        </monitorspec>
        <mode>
          <width>$xW_</width>
          <height>$yH_</height>
          <rate>50.000</rate>
        </mode>
      </monitor>
    </logicalmonitor>
  </configuration>
</monitors>
EOT
}



# -  - #
# - dconfConfiguration_ - #
function dconfConfiguration_(){
  local wDock_=https://www.education.isdevelopment.us/Ubuntu.Ins/dockSettings.txt \
        sDock_=/ \
        fDock_=~/Downloads/dockSettings.txt;
<<'comment'
  # -  - #
  # - Save gnome settings configuration - #
  sDock_=/;
  fDock_=~/Downloads/dockSettings.txt;
  dconf dump $sDock_ > $fDock_;
comment

curl -o $fDock_ $wDock_;
dconf load $sDock_ < $fDock_;
rm -rf $fDock_;
}



# -  - #
# - checkSsh_ - #
# Checks if the user is connected via SSH.
# Returns 0 (true) if SSH is detected, 1 (false) otherwise.
function checkSsh_(){
  # Using local scope protects the variable from leaking into the global script
  local sshC_="$SSH_CONNECTION"
  
  if [[ -n "$sshC_" ]]; then
    echo -e "\n\n\nThis process cannot be executed through SSH...\n\n"
    sleep 10
    return 0 # 0 means "Yes, this is an SSH session" (True)
  fi
  
  return 1 # 1 means "No SSH session detected" (False)
}



# - - #
# - Create_BT_AX900_Function_ - #
function Create_BT_AX900_Function_(){
  local sDwn_=~/Downloads/ \
        fName_=btAX900_Function_.sh;
  local btAX900_=$sDwn_$fName_;

 clear;
 echo -e "\n\n\nCreating $btAX900_ configuration file...\n"

tee "$btAX900_" << 'EOF'
#!/bin/bash
# - bof - #

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# distroVersion_ — source from hosted Functions.sh, set $DISTRO_OPT
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
DISTRO_OPT=0

# Source distro detection from hosted Functions.sh
source /dev/stdin <<< "$(curl -s --max-time 10 https://www.education.isdevelopment.us/Functions/Functions.sh 2>/dev/null)" 2>/dev/null || true
distroVersion_
DISTRO_OPT=$Opt

# Fallback if source failed
if [[ $DISTRO_OPT -eq 0 ]]; then
  if grep -qi "debian\\|ubuntu\\|zorin\\|mint\\|linuxlite" /etc/os-release 2>/dev/null; then DISTRO_OPT=1
  elif grep -qi "arch\\|artix" /etc/os-release 2>/dev/null; then DISTRO_OPT=2
  elif grep -qi "fedora\\|rhel\\|centos" /etc/os-release 2>/dev/null; then DISTRO_OPT=3
  elif grep -qi "zorin" /etc/os-release 2>/dev/null; then DISTRO_OPT=4
  elif grep -qi "mint" /etc/os-release 2>/dev/null; then DISTRO_OPT=5
  fi
fi

# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# BT_AX900_wifiInstall_ — install driver for BT-AX900 (AIC8800D80)
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function BT_AX900_wifiInstall_() {
 set -euo pipefail

 local distro_name="unknown"
 case $DISTRO_OPT in
  1|4) distro_name="debian/ubuntu/zorin" ;;
  2)   distro_name="arch" ;;
  3)   distro_name="red hat" ;;
 esac

 echo "Distro: $distro_name  |  Kernel: $kver"

 case $DISTRO_OPT in
  2) sudo pacman -S --needed --noconfirm usb_modeswitch sg3_utils git dkms linux-headers ;;
  1|4) sudo apt update && sudo apt install -y usb-modeswitch sg3-utils git dkms build-essential linux-headers-"$(uname -r)" ;;
  *) echo "❌ Unsupported distro."; return 1 ;;
 esac

 echo "--- Cleaning conflicting DKMS modules ---"
 if dkms status aic8800/radxa 2>/dev/null | grep -q .; then sudo dkms remove aic8800/radxa --all 2>/dev/null || true; fi
 for m in $(dkms status 2>/dev/null | grep aic8800dc | cut -d, -f1 | tr -d ' '); do sudo dkms remove "$m" --all 2>/dev/null || true; done
 sudo rm -f /lib/modules/"$kver"/updates/dkms/aic8800_fdrv.ko* /lib/modules/"$kver"/updates/dkms/aic_load_fw.ko* 2>/dev/null || true
 sudo modprobe -r aic8800_fdrv aic_load_fw 2>/dev/null || true
 sudo rm -rf /usr/src/aic8800-radxa /usr/src/aic8800dc-* /etc/modules-load.d/aic8800.conf 2>/dev/null || true
 sudo depmod -a
 rm -rf /tmp/AIC8800D80 /tmp/radxa-aic-* 2>/dev/null || true

 echo "--- Cloning AIC8800D80 ---"
 git clone https://github.com/olamellberg/AIC8800D80.git /tmp/AIC8800D80

 echo "--- Installing usb_modeswitch config and udev rules ---"
 sudo cp /tmp/AIC8800D80/linux/usb_modeswitch/1111_1111 /etc/usb_modeswitch.d/1111:1111
 sudo cp /tmp/AIC8800D80/linux/udev/*.rules /etc/udev/rules.d/ 2>/dev/null || true
 sudo udevadm control --reload-rules

 echo "--- Running Pandora install.sh (ignoring build failure, we patch and rebuild) ---"
 cd /tmp/AIC8800D80/linux
 set +e; sudo bash install.sh 2>&1; local install_exit=$?; set -e
 echo "  → install.sh exited with code $install_exit (expected on kernel 7.x)"
 rm -rf /tmp/radxa-aic-* 2>/dev/null || true

 if (( kmaj >= 7 )); then
  echo "--- Applying kernel 7.x fixes ---"
  local fdrv_src=/usr/src/aic8800-radxa/aic8800_fdrv
  local rwnx_main=$fdrv_src/rwnx_main.c
  local dkms_conf=/usr/src/aic8800-radxa/dkms.conf

  sudo sed -i 's/(int)in_irq()/(int)in_interrupt()/g' "$fdrv_src"/*.c 2>/dev/null || true

  sudo python3 /dev/stdin "$rwnx_main" << 'PYEOF'
import sys
path = sys.argv[1]
with open(path) as f: text = f.read()
new = ('static int rwnx_cfg80211_get_tx_power(struct wiphy *wiphy,\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)\n struct wireless_dev *wdev,\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 14, 0)\n int radio_idx,\n unsigned int link_id,\n#endif\n#endif\n\tint *mbm)')
old_a = ('static int rwnx_cfg80211_get_tx_power(struct wiphy *wiphy,\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)\n struct wireless_dev *wdev,\n#endif\n\tint *mbm)')
old_b = ('static int rwnx_cfg80211_get_tx_power(struct wiphy *wiphy,\n#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 8, 0)\n struct wireless_dev *wdev,\n#if LINUX_VERSION_CODE >= KERNEL_VERSION (6, 14, 0)\n unsigned int link_id,\n#endif\n#endif\n\tint *mbm)')
if old_a in text: text = text.replace(old_a, new, 1); print('OK: patched (pre-6.14)')
elif old_b in text: text = text.replace(old_b, new, 1); print('OK: patched (post-6.14)')
elif 'rwnx_cfg80211_get_tx_power' in text:
    lines = text.split('\n')
    for i, l in enumerate(lines):
        if 'rwnx_cfg80211_get_tx_power' in l:
            print('OK: already patched' if 'int radio_idx' in '\n'.join(lines[i:i+8]) else 'WARNING: unexpected sig')
            break
else: print('WARNING: function not found')
with open(path, 'w') as f: f.write(text)
PYEOF

  sudo python3 /dev/stdin "$dkms_conf" << 'PYEOF'
import sys
path = sys.argv[1]
with open(path) as f: lines = f.read().split('\n')
if 'KBUILD_EXTRA_SYMBOLS' in '\n'.join(lines): print('OK: already present')
else:
    for i, l in enumerate(lines):
        if l.startswith('MAKE[') and 'aic_load_fw' in l and '&&' in l:
            p = l.split('&&', 1)
            lines[i] = p[0] + '&& KBUILD_EXTRA_SYMBOLS=${dkms_tree}/aic8800/radxa/build/aic_load_fw/Module.symvers ' + p[1].lstrip()
            with open(path, 'w') as f: f.write('\n'.join(lines))
            print('OK: added KBUILD_EXTRA_SYMBOLS')
            break
    else: print('WARNING: could not patch')
PYEOF

  echo "--- Rebuilding DKMS modules with patches ---"
  sudo dkms remove aic8800/radxa -k "$kver" 2>/dev/null || true
  sudo dkms build aic8800/radxa -k "$kver"
  sudo dkms install aic8800/radxa -k "$kver"
 else
  echo "--- Kernel < 7.x, no patches needed ---"
 fi

 echo "--- Verifying modules ---"
 sudo depmod -a
 local ok=true
 for mod in aic_load_fw aic8800_fdrv; do
  if modinfo "$mod" 2>/dev/null | grep -q 'filename:'; then echo "✅ $mod: $(modinfo "$mod" | grep description | head -1)"; else echo "❌ $mod not found"; ok=false; fi
 done
 $ok || return 1

 echo "--- Enabling modules at boot ---"
 echo -e 'aic_load_fw\naic8800_fdrv' | sudo tee /etc/modules-load.d/aic8800.conf > /dev/null
 sudo depmod -a
 echo "✅ Auto-load enabled"
 echo ""
 echo "============================================"
 echo "✅ BT-AX900 Install complete!"
 echo "============================================"
 echo ""
 echo "To test: unplug/replug adapter, then:"
 echo "  iw dev"
 echo ""
}



# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Main
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
clear
distroVersion_
BT_AX900_wifiInstall_



# - eof - #
EOF



 chmod +x $btAX900_;

 cd $sDwn_;
 ls -lah $sDwn_;

 echo -e "\n\n$btAX900_ configuration file was create successfully. \
          \nThis function can't be run from ssh. \
          \nssh is exiting right now...\n\n\n";
 sleep 10;
 exit

}



# - eof - #