5 # The contents of this file are subject to the terms of the
6 # Common Development and Distribution License, Version 1.0 only
7 # (the "License"). You may not use this file except in compliance
10 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
11 # or http://www.opensolaris.org/os/licensing.
12 # See the License for the specific language governing permissions
13 # and limitations under the License.
15 # When distributing Covered Code, include this CDDL HEADER in each
16 # file and include the License file at usr/src/OPENSOLARIS.LICENSE.
17 # If applicable, add the following below this CDDL HEADER, with the
18 # fields enclosed by brackets "[]" replaced with your own identifying
19 # information: Portions Copyright [yyyy] [name of copyright owner]
23 # Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
26 LING
=${LC_CTYPE:-"$LC_ALL"}
30 XIM_SCRIPT_DIR
=/etc
/X11
/xinit
/imf.d
31 XIM_USR_CONF
=$HOME/.imf
33 IMFSELECTOR
='/usr/bin/imf-selector'
38 im_name
=`sh $imfile -name`
39 /bin
/echo "$im_name|$imfile"
45 # list available IM on system
46 if [ ! -d $XIM_SCRIPT_DIR ]; then
50 if [ X
"$s" != X
]; then
51 im_file
=`LC_ALL=C /bin/ls $XIM_SCRIPT_DIR \
52 | /bin/grep "[0-9][0-9]*\.$s\$"`
53 if [ X
$im_file != X
]; then
54 im_name
=`sh $XIM_SCRIPT_DIR/$im_file -name`
55 /bin
/echo "$im_name|$XIM_SCRIPT_DIR/$im_file"
60 LC_ALL
=C
/bin
/ls -F $XIM_SCRIPT_DIR/[0-9][0-9]* \
61 |
/bin
/egrep -v '@$|/$' |
/bin
/cut
-d'*' -f 1
66 # Check specified default engine in for language
67 # if this selection is done once and ignored, skip.
68 if [ -f $XIM_USR_CONF ]; then
72 list_ims |
while read imfile
74 prior_im
=`sh $imfile -prior $LING`
75 if [ X
"$prior_im" != X
]; then
84 # As default, enable for only specified Asian locales
86 ja
* | zh
* | ko
* | th
* |
*_IN
* )
87 tolines
`list_ims | /usr/bin/head -1`; break;;
94 # check IM scripts orderly.
95 if [ -f $XIM_USR_CONF ]; then
97 # 1. configuration in $HOME by tool
98 im_name
=`/bin/sh $XIM_USR_CONF -name`
99 if [ X
"$im_name" = X
]; then
103 if [ X
"$IGNORE" = 'X1' ]; then
107 im_data
="$im_name|$XIM_USR_CONF"
110 elif [ X
$GTK_IM_MODULE != X
]; then
112 # 2-1. user's GTK_IM_MODULE variable
113 suffix
=$GTK_IM_MODULE
114 im_data
=`list_ims $suffix`
116 elif [ X
$XMODIFIERS != X
]; then
118 # 2-2. user's XMODIFIERS variable
119 suffix
=`/bin/echo $XMODIFIERS | cut -d '=' -f 2`
120 im_data
=`list_ims $suffix`
123 if [ X
"$im_data" != X
]; then
128 # 3. system default if nothing specified
134 # copy given script file to user config file.
137 if ! touch $XIM_USR_CONF > /dev
/null
2>&1; then
138 echo "Can not access config file: $XIM_USR_CONF" 1>&2
142 msg1
="# This file is created by Input Method selector tool.\n"
143 msg2
="# Please don't edit this file manually."
144 if [ X
"$im_script" = X
]; then
145 /bin
/echo "${msg1}${msg2}" > $XIM_USR_CONF
146 elif [ X
"$im_script" = XIGNORE
]; then
147 /bin
/echo "${msg1}${msg2}" > $XIM_USR_CONF
148 /bin
/echo "IGNORE=1" >> $XIM_USR_CONF
150 /bin
/cp $im_script $XIM_USR_CONF
158 if [ X
$IM_SCRIPT != X
-a -f $IM_SCRIPT ]; then
161 if [ -x $XIM_PRG -a X
$XIM_ASDAEMON != X
]; then
163 DTSTARTIMS
=False
; export DTSTARTIMS
164 elif [ -x $XIM_PRG ]; then
166 DTSTARTIMS
=False
; export DTSTARTIMS
173 '-list') tolines
`list_ims`; exit $?
;;
174 '-default') get_default_im
; exit $?
;;
175 '-get') get_current_im
; exit $?
;;
176 '-set') set_im
$2; exit $?
;;
179 PRIOR_IM
=`get_prior_im`
180 if [ X
"$PRIOR_IM" != X
]; then
181 (sleep 10 && $IMFSELECTOR -p "$PRIOR_IM") &
183 IM_SCRIPT
=`get_current_im | cut -d '|' -f 2`