Thanks, Aron, for addressing this issue.

On 2012-12-02 15:53, Aron Xu wrote:
> I'm not sure whether file in /etc/X11/xinit/xinput.d is considered
> out-dated once im-switch is gone, but currently it's a reliable way to
> detect which input methods have been installed.

In another discussion I mentioned two examples of why I don't think
that's a reliable method, at least not in an im-config context:

* uim 'pollutes' /etc/X11/xinit/xinput.d/ with a few files whose names
  are not valid input methods.

* nabi adds a file with just that name, while im-config's idea of the
  method name is 'hangul'.

Attached please find a patch that would implement an option to list
installed input methods. Maybe it can be done more elegantly, but the
patch is at least something to start with.

One thing I'd like to mention is that I excluded 'xim' from the list. If
I understand it correctly, the xim option does not launch any input
method daemon. To be honest I don't really know what it is, so I may
well be totally wrong here.

-- 
Gunnar Hjalmarsson
https://launchpad.net/~gunnarhj
Description: Add an -l option that prints installed IMs to STDOUT
Bug: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=694941
Author: Gunnar Hjalmarsson <gunna...@ubuntu.com>

--- im-config-0.19.orig/im-config	2012-05-15 16:06:29.000000000 +0200
+++ im-config-0.19/im-config	2012-12-14 00:06:14.935854029 +0100
@@ -69,6 +69,16 @@
         write_config $IM_CONFIG_NAME $IM_CONFIG_XINPUTRC
         exit
         ;;
+    -l) for IM_CONFIG_PATH in $IM_CONFIG_DATA/[12345678][0123456789]_*.rc ; do
+            IM_CONFIG_NAME=$(name_im $IM_CONFIG_PATH)
+            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

--- 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

Reply via email to