#!/bin/sh
# vim:set et sts=4 sw=4
#
# ibus-hunspell-table - The Tables engine for IBus
#
# Copyright (c) 2011-2012 Anish Patil <anish.developer@gmail.com>
# Copyright (c) 2013 Mike FABIAN <mfabian@redhat.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#  This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#  You should have received a copy of the GNU General Public License 
# along with this program.  If not, see <http://www.gnu.org/licenses/>

prefix=/usr
datarootdir=${prefix}/share
datadir=/usr/share
export IBUS_HUNSPELL_TABLE_LOCATION=${prefix}/share/ibus-typing-booster

# Set this variable to something > 0 to get more debug output.
# (Debug output may show up in the log file and/or in the lookup table):
# export IBUS_TYPING_BOOSTER_DEBUG_LEVEL=1
#
# set this to some file if you want benchmarking
# export IBUS_TYPING_BOOSTER_PROFILE_FILE=/tmp/ibus-typing-booster.profile
#
# Then after using ibus-typing-booster for a while, stop it with “ibus exit”
# and check the profile data with a python script like (for more  see
# http://docs.python.org/2/library/profile.html):
#
# import pstats
# p = pstats.Stats('/tmp/ibus-typing-booster.profile')
# p.strip_dirs()
# p.sort_stats('cumulative')
# p.print_stats('tabsqlite', 25)

for arg in $@; do
	case $arg in
	--xml | -x)
		exec python ${prefix}/share/ibus-typing-booster/engine/main.py --xml;;
	--help | -h)
		exec python ${prefix}/share/ibus-typing-booster/engine/main.py $@;;
        *)
		if [ "x${IBUS_TYPING_BOOSTER_PROFILE_FILE}" != "x" ]; then
		        rm -f ${IBUS_TYPING_BOOSTER_PROFILE_FILE}
                        exec python -m cProfile -o ${IBUS_TYPING_BOOSTER_PROFILE_FILE} ${prefix}/share/ibus-typing-booster/engine/main.py $@
                else
                        exec python ${prefix}/share/ibus-typing-booster/engine/main.py $@
                fi
                exit 0
                ;;
	esac
done

