1 |
#!/bin/bash |
2 |
|
3 |
# read the user (~/.i18n) or system-wide (/etc/sysconfig/i18n) i18n settings |
4 |
. /etc/profile.d/10lang.sh |
5 |
|
6 |
# The Gnome applets must not be launched each time if they are already |
7 |
# managed by Gnome; here is the file path to the Gnome Applets config file; |
8 |
# so we can do a grep to see if a given applet is already managed by Gnome |
9 |
GNOME_APPLET_CONFIG="$HOME/.gnome/panel.d/default/Applet_Config" |
10 |
|
11 |
if [ -z "$XIM_PROGRAM" -a -z "$XIM" ]; then |
12 |
locale=C |
13 |
if [ ! -z "$LC_ALL" ]; then |
14 |
locale=$LC_ALL |
15 |
elif [ ! -z "$LC_CTYPE" ]; then |
16 |
locale=$LC_CTYPE |
17 |
elif [ ! -z "$LANG" ]; then |
18 |
locale=$LANG |
19 |
fi |
20 |
case $locale in |
21 |
zh_TW*) |
22 |
XIM=xcin |
23 |
;; |
24 |
zh_CN*) |
25 |
XIM=Chinput |
26 |
;; |
27 |
ja*) |
28 |
XIM=uim-anthy |
29 |
;; |
30 |
ko*) |
31 |
XIM=Ami |
32 |
;; |
33 |
*) |
34 |
XIM=none |
35 |
;; |
36 |
esac |
37 |
fi |
38 |
if [ -z "$XIM_PROGRAM" ]; then |
39 |
case "$XIM" in |
40 |
Chinput) XIM_PROGRAM=chinput ;; |
41 |
xcin*) XIM_PROGRAM=xcin ;; |
42 |
uim-*) XIM_PROGRAM=uim-xim ;; |
43 |
kinput2) XIM_PROGRAM=kinput2 ;; |
44 |
Ami) |
45 |
# now ami determine which mode it will take from $DESKTOP variable |
46 |
# (not from this script's first argument given by Xsession script) |
47 |
# i think this way seems better. |
48 |
# -- Jaegeum -- |
49 |
case $DESKTOP in |
50 |
# Gnome init program automatically restore previous session's |
51 |
# ami_applet. If you put ami_applet here, you may experience a lot of |
52 |
# repeated error windows that report "an applet died abruptly". |
53 |
# so we first check if the ami_applet is referenced in Gnome config |
54 |
# files |
55 |
|
56 |
# I think removing ` and ` around grep command is more reasonable. |
57 |
# -- Jaegeum -- |
58 |
Gnome|GNOME|gnome) |
59 |
if [ -f "$GNOME_APPLET_CONFIG" ] && \ |
60 |
grep -q '\<ami_applet\>' "$GNOME_APPLET_CONFIG"; |
61 |
then |
62 |
XIM_PROGRAM=/bin/true |
63 |
elif [ -x /usr/bin/ami_applet ]; then |
64 |
XIM_PROGRAM=ami_applet |
65 |
else |
66 |
XIM_PROGRAM=ami |
67 |
fi ;; |
68 |
# Now new wmami supports KDE2 docking mode. |
69 |
# XIM_PROG_ARGS variable is added to send xim's arguments if |
70 |
# they are needed. |
71 |
# -- Jaegeum -- |
72 |
KDE|Kde|kde) |
73 |
XIM_PROGRAM=wmami;; |
74 |
WindowMaker|WINDOWMAKER|Windowmaker|windowmaker) |
75 |
XIM_PROGRAM=wmami;; |
76 |
# Following three WM entries should be added |
77 |
# because that wmami supports them is already well known fact. |
78 |
# -- Jaegeum -- |
79 |
AfterStep|AFTERSTEP|Afterstep|afterstep) |
80 |
XIM_PROGRAM=wmami;; |
81 |
Enlightenment|ENLIGHTENMENT|enlightenment) |
82 |
XIM_PROGRAM=wmami;; |
83 |
BlackBox|BLACKBOX|Blackbox|blackbox) |
84 |
XIM_PROGRAM=wmami;; |
85 |
*) |
86 |
XIM_PROGRAM=ami ;; |
87 |
esac ;; |
88 |
*) XIM_PROGRAM=/bin/true ;; |
89 |
esac |
90 |
fi |
91 |
[ -z "$XMODIFIERS" -a -n "$XIM" ] && export XMODIFIERS="@im=$XIM" |
92 |
|
93 |
if which $XIM_PROGRAM >/dev/null 2>/dev/null |
94 |
then |
95 |
# minichinput has problems running on utf-8 locales |
96 |
if [ "$XIM_PROGRAM" = "chinput" ] ; then |
97 |
case "$LANG" in |
98 |
zh_TW*|zh_HK*) LANG=zh_TW LC_ALL=zh_TW chinput $XIM_PROG_ARGS & |
99 |
;; |
100 |
*) LANG=zh_CN LC_ALL=zh_CN chinput $XIM_PROG_ARGS & |
101 |
;; |
102 |
esac |
103 |
else |
104 |
$XIM_PROGRAM $XIM_PROG_ARGS & |
105 |
fi |
106 |
fi |
107 |
|