#!/bin/sh

case "`id`" in
  uid=0\(*) : ;;
  *) echo "You must be root to run this script"
     echo "run this first then try again"
     echo "    sudo gainroot"
     exit 1
  ;;
esac

OK() { 

  message="$1"
  shift
  "$@"
  res=$?
  case "$res" in
    0) echo "$message...OK"
       return 0
    ;;
    *)
       echo "$message...FAILED[$res]"
       return $res
    ;;
  esac
}



if grep -i "^scim" /etc/gtk-2.0/gtk.immodules > /dev/null  ; then
  if OK 'Backing up gtk.immodules' cp /etc/gtk-2.0/gtk.immodules /etc/gtk-2.0/gtk.immodules.fixkbd ; then
    OK 'Attempting to patch gtk.immodules'  sed -i 's~^\("[^"]*/im-scim.so"\)~#\1~
    s~^\("scim"\)~#\1~' /etc/gtk-2.0/gtk.immodules
  fi
fi

if [ -x /opt/maemocjk/usr/bin/imdefault ] ; then
  OK 'Calling /opt/maemocjk/usr/bin/imdefault'   /opt/maemocjk/usr/bin/imdefault   
  
fi

case "`gconftool-2 -g /apps/osso/inputmethod/default-plugins/finger`" in
  hildon_western_fkb) : ;;
  *)
  OK 'Resetting /apps/osso/inputmethod/default-plugins/finger'   gconftool-2 -s -t string /apps/osso/inputmethod/default-plugins/finger hildon_western_fkb

  ;;
esac



