# 50-xterm
# detect and set terminal type in profile

#----------------------------------------------------------------------
# set terminal type var in profile
SetTrm() {
   TERM="$1"
   sed -i '/^TERM=/d' $ProFile
   echo "export TERM=$TERM" >> $ProFile
} # SetTrm

#----------------------------------------------------------------------
# find known terminal types, and set var in profile
FinTrm() {
   if dmesg | grep -qi "Xen version:" ; then
      SetTrm "xterm"
   else
      a=$(timeout 3 dmidecode -s system-product-name 2>/dev/null)
      if [ "$a" == "KVM" ] || [ "$a" == "Xen" ] ; then
         SetTrm "xterm"
      fi
   fi
} # FinTrm

#----------------------------------------------------------------------
# Main
ProFile=/etc/Profile
FinTrm

