#!/bin/bash
. ./lib

options=()

package=""
items=$(pacman -Sqg $package)
for item in $items; do
  case $item in
    "dolphin" | \
    "kate" | \
    "kdialog" | \
    "kfind" | \
    "konsole" | \
    "kwrite" | \
    "kcron" | \
    "ksystemlog" | \
    "ark" | \
    "kcalc" | \
    "kcharselect" | \
    "kgpg" | \
    "kwalletmanager" | \
    "print-manager" | \
    "gwenview" | \
    "kcolorchooser" | \
    "kdegraphics-mobipocket" | \
    "kdegraphics-thumbnailers" | \
    "kolourpaint" | \
    "okular" | \
    "spectacle" | \
    "audiocd-kio" | \
    "ffmpegthumbs" | \
    "kmix" | \
    "kdenetwork-filesharing" | \
    "filesharing" | \
    "kio-extras" | \
    "signon-kwallet-extension" | \
    "zeroconf-ioslave" | \
    "kdesdk-thumbnailers" | \
    "thumbnailers") options+=("$item" "" on);;
    *) options+=("$item" "" off);;
  esac
done

sel=$(whiptail --backtitle "$apptitle" --title "$package Install :" --checklist "" --cancel-button "Back" 0 0 0 \
  "${options[@]}" \
  3>&1 1>&2 2>&3)

if [ ! "$?" = "0" ]; then
  exit 1
fi

for itm in $sel; do
  pkg="$pkg $(echo $itm | sed 's/"//g')"
done

instpkg "$pkg" "$aurpkg"

exit 0