#!/usr/bin/env bash
source ~/.local/share/Panama/bin/ascii
# Set host name
echo -e "Current hostname is: $(hostname)"
read -p "Do you want to change the hostname? [y/N]: " confirm_change
if [[ "$confirm_change" =~ ^[Yy]$ ]]; then
  read -p "Hostname: " HOST_NAME
  read -p "Set hostname to '$HOST_NAME'? [y/N]: " confirm_hostname
  if [[ "$confirm_hostname" =~ ^[Yy]$ ]]; then
    sudo hostnamectl set-hostname "$HOST_NAME"
    echo "Hostname set to: $(hostname)"
  else
    echo "Hostname not changed."
  fi
else
  echo "Not changing hostname."
  exit
fi

# Ensure computer doesn't go to sleep.
gsettings set org.gnome.desktop.screensaver lock-enabled false
gsettings set org.gnome.desktop.session idle-delay 0

# Run each setup stage in its own process. This keeps strict-shell options and
# helper variables local to the script that owns them.
for script in ~/.local/share/Panama/setup/scripts/*; do "$script"; done

# Revert to normal idle settings
gsettings set org.gnome.desktop.screensaver lock-enabled true
gsettings set org.gnome.desktop.session idle-delay 300
