#!/usr/bin/env bash

export TEXTDOMAIN='setup-great-os'
export TEXTDOMAINDIR='/usr/share/locale'
. gettext.sh



setup_lxde() {
  sudo cards install great-os-wallpaper gvfs lightdm-gtk-greeter lxde lxde-extra \
    xorg-xf86-input-synaptics xdg-user-dirs xorg-server xorg-xinit xorg-setxkbmap \
    xorg-xrandr networkmanager galculator pluma plasma-nm xarchiver
  sudo systemctl enable -f lightdm NetworkManager
}

setup_mate() {
  sudo cards install great-os-wallpaper network-manager-applet gvfs lightdm-gtk-greeter \
    mate mate-extra xdg-user-dirs xorg-server xorg-xinit \
    xorg-xf86-input-synaptics xorg-setxkbmap xorg-xrandr gnome-disk-utility
  sudo systemctl enable -f lightdm NetworkManager
}

setup_xfce() {
  sudo cards install great-os-wallpaper network-manager-applet gvfs lightdm-gtk-greeter \
    xfce xfce-extra xdg-user-dirs xorg-server xorg-xinit \
    xorg-xf86-input-synaptics xorg-setxkbmap xorg-xrandr galculator
  sudo systemctl enable -f lightdm NetworkManager
}

setup_gnome() {
  sudo cards install great-os-wallpaper network-manager-applet gvfs gdm gnome3 gnome3-apps \
    xdg-user-dirs xorg-server xorg-xinit gnome-disk-utility \
    xorg-xf86-input-synaptics xorg-setxkbmap xorg-xrandr gnome-bluetooth3
  sudo systemctl enable -f NetworkManager bluetooth gdm
}

setup_plasma() {
  sudo cards install great-os-wallpaper gvfs sddm plasma plasma-extra \
    xorg-xf86-input-synaptics xorg-setxkbmap xorg-xrandr breeze-gtk xdg-user-dirs xorg-server xorg-xinit \
    networkmanager plasma-nm
  sudo systemctl enable -f sddm NetworkManager
}

setup_lxqt() {
  sudo cards install great-os-wallpaper gvfs sddm lxqt lxqt-extra \
    breeze-gtk xdg-user-dirs xorg-server xorg-xinit xorg-setxkbmap \
    xorg-xf86-input-synaptics xorg-xrandr networkmanager plasma-nm ark
  sudo systemctl enable -f sddm NetworkManager
}

setup_enlightenment() {
  sudo cards install great-os-wallpaper connman gvfs sddm e18n xdg-user-dirs
    xorg-server xorg-xinit xorg-xf86-input-synaptics xorg-setxkbmap \
    xorg-xrandr libinput xwayland xarchiver
  sudo systemctl enable -f sddm connman
}

setup_pantheon() {
  sudo cards install -f great-os-wallpaper network-manager-applet gvfs pantheon pantheon-extra \
    xorg-xf86-input-synaptics xdg-user-dirs xorg-server xorg-xinit \
    xorg-setxkbmap xorg-xrandr gnome-bluetooth3 tumbler
  sudo systemctl enable -f lightdm NetworkManager bluetooth
}

setup_cosmic() {
  sudo cards install -f great-os-wallpaper gvfs cosmic cosmic-extra \
    xorg-xf86-input-synaptics xdg-user-dirs xorg-server xorg-xinit \
    xorg-setxkbmap xorg-xrandr greetd xwayland
  sudo systemctl enable -f cosmic-greeter NetworkManager bluetooth
}

tmpfile="/tmp/choix$$"

dialog --title "   $(gettext "Great-OS Desktop Environment Installer")   " \
--colors --menu "$(gettext "Available desktop environments")"  0 0 0 \
1 "$(gettext "LXDE")" \
2 "$(gettext "MATE")" \
3 "$(gettext "XFCE")" \
4 "$(gettext "GNOME")" \
5 "$(gettext "PLASMA")" \
6 "$(gettext "Enlightenment")" \
7 "$(gettext "Cosmic")" \
2>$tmpfile

retval=$?
choice=$(cat $tmpfile)
# echo "retval: $retval ; choice: $choice"
clear

cards sync

if [ $retval == 0 ]; then

  case $choice in
  1)
    setup_lxde
    ;;
  2)
    setup_mate
    ;;
  3)
    setup_xfce
    ;;
  4)
    setup_gnome
    ;;
  5)
    setup_plasma
    ;;
  6)
    setup_enlightenment
    ;;
  7)
    setup_cosmic
    ;;
  esac
fi
