#!/bin/sh 
export PATH=/usr/local/netpbm/bin:/usr/X11R6/bin:/usr/bin:/bin:/usr/local/canna/bin
cd

exec > .xinitrc.log 2> .xinitrc.log

export LANG=ja_JP.eucJP
export XMODIFIERS='@im=kinput2'

killall() {
  ps -as | grep $1 | while read line
  do
    set $line
    kill $1
  done
}

cannaserver=echo
cannakill=echo
if [ -f /usr/sbin/canna2imm32.exe ]; then
    cannaserver="/usr/sbin/canna2imm32 -nolog -inet"
elif [ -f /usr/local/canna/sbin/cannaserver.exe ]; then
    cannaserver="/usr/local/canna/sbin/cannaserver -inet"
    cannakill=/usr/local/canna/sbin/cannakill
fi

$cannakill
rm -rf /tmp/.iroha_unix
$cannaserver
# the keyboard layout is determined automatically.
#setxkbmap jp
#setxkbmap us
if [ -f $HOME/.Xresources ]; then
    xrdb -override $HOME/.Xresources
fi
if [ -d $HOME/.ttfonts ]; then
    xset fp+ $HOME/.ttfonts
fi
#xset fp+ /usr/share/fonts/mplus

if [ -f $HOME/.canna ]; then
    kinput2 -canna -cannaserver localhost -cannafile $HOME/.canna &
else
    kinput2 -canna -cannaserver localhost &
fi

#twm &
#wmaker &
#openbox &
#fvwm2 &

#xterm -u8 +lc -geometry 80x40+0+0 -title 'xterm' -e tcsh &
#/usr/bin/kterm -geometry 80x25-5+0 -title 'kterm' -km sjis -e tcsh &
#/usr/bin/kterm -geometry 80x25-5-30 -title 'kterm-euc' -km euc -e tcsh &
#/usr/bin/kterm -geometry 80x48+5+5 -title 'kterm main' -km sjis -e tcsh
xterm -geometry 80x5+0+0 -title 'xterm' -sb -e tcsh &
xeyes -geometry +580+0 &
#xclock -geometry +580+130 &
kterm -geometry 80x40-5+5 -title 'kterm(sjis)' -km sjis -sb -sl 2000 -e tcsh &
kterm -geometry 80x66+0+5 -title 'kterm(sjis)' -km sjis -sb -sl 2000 -e tcsh


killall kterm
killall -9 tcsh
$cannakill
# if cannakill could not terminate cannaserver...
killall $cannaserver
rm -rf /tmp/.iroha_unix
