Hi Osamu, I've attached a patch which applies against the im-switch 1.16 source package. This patch contains the least controversial changes:
* Create some common functions to avoid code duplication. * Deprecate "all_ALL". * Introduce pseudo-locale "fallback", unfortunately "default" is used in another context as a 'type' of IM. I have tested this patch briefly, please review it. If there are any changes that need to be made, I'm happy to update the patch. There is a second patch which would apply on top of this one, but that maybe more controversial. cya, # -------------------------------------------------------------------- diff --git a/debian/postinst b/debian/postinst index e677f69..40e090b 100644 --- a/debian/postinst +++ b/debian/postinst @@ -33,9 +33,9 @@ fi case "$1" in configure) # Set up default - ua_inst all_ALL default 10 - ua_inst all_ALL default-xim 0 - ua_inst all_ALL none 0 + ua_inst fallback default 10 + ua_inst fallback default-xim 0 + ua_inst fallback none 0 # Set up *-xim ua_inst th_TH th-xim 20 ;; diff --git a/debian/prerm b/debian/prerm index 2be2b06..33b4461 100644 --- a/debian/prerm +++ b/debian/prerm @@ -10,11 +10,15 @@ ua_remove () { case "$1" in remove|upgrade|deconfigure) # remove defaults + ua_remove fallback default + ua_remove fallback default-xim + # remove nones + ua_remove fallback none + ua_remove th_TH th-xim + # all_ALL is deprecated but it needs to be removed too. ua_remove all_ALL default ua_remove all_ALL default-xim - # remove nones ua_remove all_ALL none - ua_remove th_TH th-xim ;; failed-upgrade) ;; diff --git a/im-switch b/im-switch index b9f73e2..683ebb1 100755 --- a/im-switch +++ b/im-switch @@ -20,12 +20,12 @@ ALTER_XINPUT=/etc/alternatives/xinput- # location for special hook scripts installed by each IM packages HOOKDIR=/usr/share/im-switch -# $LNG is locale <languag>e_<region> without .<encoding> and .<encoding>@EURO +# $LNG is locale <language>_<region> without .<encoding> and .<encoding>@EURO LNG=${LC_ALL:-${LC_CTYPE:-${LANG}}} lng=${l...@*} LNG=${LNG%.*} -[ -z "$LNG" ] && LNG="all_ALL" || true +[ -z "$LNG" ] && LNG="fallback" || true USERID=$(id -u) VER=0.3+debian1.10 @@ -103,18 +103,24 @@ dependency() { fi } +_current_system_im_for_locale() { + locale="$1" + /usr/sbin/update-alternatives --display xinput-${locale} | \ + sed -ne 's/ link currently points to \(.*\)/\1/p' | \ + sed -e "s%${XINPUT_PATH}/%%" +} + # echo current system wide default IM setup name current_system_im () { if [ -r "${ALTER_XINPUT}${LNG}" ]; then - /usr/sbin/update-alternatives --display xinput-$LNG | \ - sed -ne 's/ link currently points to \(.*\)/\1/p' | \ - sed -e "s%${XINPUT_PATH}/%%" + _current_system_im_for_locale ${LNG} + elif [ -r "${ALTER_XINPUT}fallback" ]; then + _current_system_im_for_locale "fallback" + # TODO: all_ALL is deprecated and should be removed eventually. elif [ -r "${ALTER_XINPUT}all_ALL" ]; then - /usr/sbin/update-alternatives --display xinput-all_ALL | \ - sed -ne 's/ link currently points to \(.*\)/\1/p' | \ - sed -e "s%${XINPUT_PATH}/%%" + _current_system_im_for_locale "all_ALL" else - echo "No system wide default \"${ALTER_XINPUT}${LNG} or ${ALTER_XINPUT}all_ALL\" is defined." + echo "No system wide default \"${ALTER_XINPUT}${LNG}\" or \"${ALTER_XINPUT}fallback\" is defined." exit 1 fi } @@ -144,39 +150,43 @@ runhookscripts () { fi } +_print_private_im_for_locale() { + locale="$1" + + if [ -L "${DOTXINPUT_PATH}/${locale}" ]; then + echo "The configuration \"${DOTXINPUT_PATH}/${locale}\" is defined as a link pointing to:" + echo "$(basename $(readlink "${DOTXINPUT_PATH}/${locale}"))" + else + echo "The private configuration is a static file \"${DOTXINPUT_PATH}/${locale}\" ." + fi + echo "This private configuration supersedes the system wide default." +} + +_print_system_im_for_locale() { + locale="$1" + echo "The system wide default is pointed by \"${ALTER_XINPUT}${locale}\" ." + /usr/sbin/update-alternatives --display xinput-${locale} | sed -e "s%$XINPUT_PATH/%%" +} + list() { echo "Your input method setup under $LNG locale as below." echo "=======================================================" if [ "$USERID" -eq 0 ]; then echo "No private configuration can be defined for root account." elif [ -r "${DOTXINPUT_PATH}/${LNG}" ]; then - if [ -L "${DOTXINPUT_PATH}/${LNG}" ]; then - echo "The configuration \"${DOTXINPUT_PATH}/${LNG}\" is defined as a link pointing to" - echo "$(basename $(readlink "${DOTXINPUT_PATH}/${LNG}"))" - else - echo "The private configuration is a static file \"${DOTXINPUT_PATH}/${LNG}\" ." - fi - echo "This private configuration supersedes the system wide default." - elif [ -L "${DOTXINPUT_PATH}/all_ALL" ]; then - if [ -L "${DOTXINPUT_PATH}/all_ALL" ]; then - echo "The configuration \"${DOTXINPUT_PATH}/all_ALL\" is defined as a link pointing to" - echo "$(basename $(readlink "${DOTXINPUT_PATH}/all_ALL"))" - else - echo "The private configuration is a static file \"${DOTXINPUT_PATH}/all_ALL\" ." - fi - echo "This private configuration supersedes the system wide default." + _print_private_im_for_locale ${LNG} + elif [ -r "${DOTXINPUT_PATH}/fallback" ]; then + _print_private_im_for_locale "fallback" else - echo "No private \"${DOTXINPUT_PATH}/${LNG} or ${DOTXINPUT_PATH}/all_ALL\" is defined." + echo "No private \"${DOTXINPUT_PATH}/${LNG}\" or \"${DOTXINPUT_PATH}/fallback\" is defined." fi echo "=======================================================" if [ -r "${ALTER_XINPUT}${LNG}" ]; then - echo "The system wide default is pointed by \"${ALTER_XINPUT}${LNG}\" ." - /usr/sbin/update-alternatives --display xinput-$LNG | sed -e "s%$XINPUT_PATH/%%" - elif [ -r "${ALTER_XINPUT}all_ALL" ]; then - echo "The system wide default is pointed by \"${ALTER_XINPUT}all_ALL\" ." - /usr/sbin/update-alternatives --display xinput-all_ALL | sed -e "s%$XINPUT_PATH/%%" + _print_system_im_for_locale ${LNG} + elif [ -r "${ALTER_XINPUT}fallback" ]; then + _print_system_im_for_locale "fallback" else - echo "No system wide default \"${ALTER_XINPUT}${LNG} or ${ALTER_XINPUT}all_ALL\" is defined." + echo "No system wide default \"${ALTER_XINPUT}${LNG}\" or \"${ALTER_XINPUT}fallback\" is defined." fi vecho "=======================================================" vecho "The system wide default input methods are available for the locales:" @@ -203,14 +213,18 @@ list() { echo "=======================================================" } +_check_n_set_im_locale() { + if [ ! -r "${ALTER_XINPUT}${LNG}" ]; then + echo "No system wide default defined just for locale $LNG ." + echo "Use \"fallback\" quasi-locale and set IM." + LNG="fallback" + fi +} + # set IM to defaults auto() { if [ "$USERID" -eq 0 ]; then - if [ ! -r "${ALTER_XINPUT}${LNG}" ]; then - echo "No system wide default defined just for locale ${LNG} ." - echo "Use \"all_ALL\" quasi-locale and set IM." - LNG="all_ALL" - fi + _check_n_set_im_locale PREVIOUS=$(current_system_im) /usr/sbin/update-alternatives --auto xinput-$LNG else @@ -234,11 +248,7 @@ setalt() { echo "Error: No action taken." >&2 exit 1 fi - if [ ! -r "${ALTER_XINPUT}${LNG}" ]; then - echo "No system wide default defined just for locale $LNG ." - echo "Use \"all_ALL\" quasi-locale and set IM." - LNG="all_ALL" - fi + _check_n_set_im_locale PREVIOUS=$(current_system_im) /usr/sbin/update-alternatives --set xinput-$LNG $XINPUT_PATH/${1} DEFAULT=$(current_system_im) @@ -276,11 +286,7 @@ setalt() { cfgalt() { if [ "$USERID" -eq 0 ]; then vecho "You are root user." - if [ ! -r "${ALTER_XINPUT}${LNG}" ]; then - echo "No system wide default defined just for locale $LNG ." - echo "Use \"all_ALL\" quasi-locale and set IM." - LNG="all_ALL" - fi + _check_n_set_im_locale PREVIOUS=$(current_system_im) echo "System wide default for ${LNG} locale is marked with [+]." /usr/sbin/update-alternatives --config xinput-$LNG @@ -335,7 +341,7 @@ cfgalt() { echo " $INDEX $i" fi done - echo "System wide default for ${LNG} (or all_ALL) locale is marked with [+]." + echo "System wide default for ${LNG} (or fallback) locale is marked with [+]." echo -n "Press enter to keep the current selection[*], or type selection number: " read SEL echo diff --git a/im-switch.8 b/im-switch.8 index 11bab70..6333b29 100644 --- a/im-switch.8 +++ b/im-switch.8 @@ -37,7 +37,7 @@ wide default using Debian alternatives mechanism with link. .PP The X start up code sources -.B /etc/X11/Xsession.d/90im-switch +.B /etc/X11/Xsession.d/80im-switch which read the configuration file and activates the input method. The user configuration files and links are located in .B ~/.xinput.d/ . @@ -51,11 +51,12 @@ understands the following options: Display verbose message during execution. .TP .BR \-z " ll_CC" -Set up the input method for X run under +Set up the input method only for the .B ll_CC -locale (ISO 639 / ISO 3188). When setting for all locales, use -.B all_ALL -as the quasi-locale value here. +locale (ISO 639 / ISO 3166). To set a fallback default, use +.B fallback +as a quasi-locale value. This will be selected when no real locales have +been set. .TP .BR \-s " inputmethodname" Set up the input method to use inputmethodname. @@ -71,6 +72,12 @@ List the input method configuration. .TP .BR \-h Print a help message to the standard output and exit. +.SH "NOTES" +The quasi-locale +.B all_ALL +has been deprecated. Please use +.B fallback +instead. .SH "SEE ALSO" .BR update\-alternatives (8) .BR /usr/share/doc/im\-switch/README.Debian diff --git a/xinput.sh b/xinput.sh index 8d54c83..6a8f1f1 100755 --- a/xinput.sh +++ b/xinput.sh @@ -12,6 +12,8 @@ # # X Input method setup script +PROGNAME=`basename $0` + # Keep original values related to IM _XIM=$XIM _XIM_PROGRAM=$XIM_PROGRAM @@ -25,18 +27,25 @@ LNG=${LC_ALL:-${LC_CTYPE:-${LANG}}} lng=${l...@*} LNG=${LNG%.*} -[ -z "$LNG" ] && LNG="all_ALL" || true +[ -z "$LNG" ] && LNG="fallback" || true echo "Setting IM through im-switch for locale=$LNG." # Source first found configuration under $LNG locale for f in "$HOME/.xinput.d/${LNG}" \ + "$HOME/.xinput.d/fallback" \ "$HOME/.xinput.d/all_ALL" \ "/etc/X11/xinit/xinput.d/${LNG}" \ + "/etc/X11/xinit/xinput.d/fallback" \ "/etc/X11/xinit/xinput.d/all_ALL" \ "/etc/X11/xinit/xinput.d/default" ; do if [ -f "$f" -a -r "$f" ]; then echo "Start IM through $f linked to $(readlink -f $f)." + + if echo $f | grep -q 'all_ALL$'; then + echo "${PROGNAME}: WARNING: the quasi-locale \"all_ALL\" is deprecated, please use \"fallback\" instead. Refer to im-switch(8)." >&2 + fi + . "$f" break fi -------------------------------------------------------------------- -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org