I decided to give the code reuse idea a shot, and the result is the attached patch. It's not much that can be done, really.
Better than the first patch? I'm not sure. -- Gunnar Hjalmarsson https://launchpad.net/~gunnarhj
Description: Add an -l option that prints installed IMs to STDOUT Bug: http://bugs.debian.org/694941 Author: Gunnar Hjalmarsson <[email protected]> --- im-config-0.19.orig/im-config 2012-05-15 16:06:29.000000000 +0200 +++ im-config-0.19/im-config 2012-12-17 07:30:58.951384171 +0100 @@ -37,6 +37,17 @@ # console dialog IM_CONFIG_DIALOG="console" fi +get_im_config_names() { + if [ -n "$1" -a "$1" = 'menu_list' ]; then + IM_CONFIG_DATA_REGEX='[012345678][0123456789]_*.rc' + else + IM_CONFIG_DATA_REGEX='[12345678][0123456789]_*.rc' + fi + IM_CONFIG_NAMES= + for IM_CONFIG_PATH in $IM_CONFIG_DATA/$IM_CONFIG_DATA_REGEX; do + IM_CONFIG_NAMES="$IM_CONFIG_NAMES $(name_im $IM_CONFIG_PATH)" + done +} ############################################################# # Perse command line arguments @@ -69,6 +80,16 @@ write_config $IM_CONFIG_NAME $IM_CONFIG_XINPUTRC exit ;; + -l) get_im_config_names + for IM_CONFIG_NAME in $IM_CONFIG_NAMES; do + if avail_menu $IM_CONFIG_NAME && [ $IM_CONFIG_NAME != "none" ] && + [ $IM_CONFIG_NAME != "xim" ]; then + IM_CONFIG_AVAIL="$IM_CONFIG_AVAIL $IM_CONFIG_NAME" + fi + done + echo $IM_CONFIG_AVAIL + exit 0 + ;; *) eval_gettext \ "\$IM_CONFIG_ID @@ -117,8 +138,8 @@ # Check number of installed input methods (10-89) IM_CONFIG_NUMBER=0 IM_CONFIG_AVAIL="" -for IM_CONFIG_PATH in $IM_CONFIG_DATA/[12345678][0123456789]_*.rc ; do - IM_CONFIG_NAME=$(name_im $IM_CONFIG_PATH) +get_im_config_names +for IM_CONFIG_NAME in $IM_CONFIG_NAMES; do if avail_menu $IM_CONFIG_NAME && [ $IM_CONFIG_NAME != "none" ]; then IM_CONFIG_NUMBER="$(($IM_CONFIG_NUMBER + 1))" IM_CONFIG_AVAIL="$IM_CONFIG_AVAIL $IM_CONFIG_NAME" @@ -175,8 +196,8 @@ "$(gettext "description")" )" # Make selection menu list (00-89) - for IM_CONFIG_PATH in $IM_CONFIG_DATA/[012345678][0123456789]_*.rc ; do - IM_CONFIG_NAME=$(name_im $IM_CONFIG_PATH) + get_im_config_names 'menu_list' + for IM_CONFIG_NAME in $IM_CONFIG_NAMES; do IM_CONFIG_NAME_SHORT="$(dsc_short $IM_CONFIG_NAME)" if $IM_CONFIG_ALL || avail_menu $IM_CONFIG_NAME ; then if [ "$IM_CONFIG_NAME" = "$IM_CONFIG_ACTIVE" ]; then --- im-config-0.19.orig/im-config.8 2012-11-28 15:51:57.000000000 +0100 +++ im-config-0.19/im-config.8 2012-12-13 23:52:39.631811155 +0100 @@ -37,6 +37,12 @@ When this \fI<input method name>\fP is "REMOVE" then it always removes the configuration file even if it was not updated by \fBim-config\fP. +.TP 8 +.B \-l +List installed input methods that \fBim-config\fP supports. + +This option prints the names of the installed input methods to STDOUT, and +can be used by UIs in other packages. .SH "DESCRIPTION" This manual page very briefly documents \fBim\-config\fP and the configuration

