sil2100//vx developer log

Welcome to my personal web page

Maliit Input Method

Recently, I did some experimenting with the available OSK's (on-screen keyboards) around, ultimately focusing my attention on Maliit. Maliit is an OSK project mainly known for its use on the MeeGo mobile platform - but in reality it can also be used as an input method for both Qt and GTK+ standard applications on any Linux based operating system. Since the project is being actively developed and changes are made quite rapidly, a bit of work was needed to make it work for all possible IM cases. Nothing too complicated though. Let me help you dive in into the world of Maliit. Big thanks to all Maliit developers for their swift and professional help!

2011-11-02 20:59


Maliit is certainly a great OSK framework. Its design and implementation allow for much customization, with the default environment providing 'all that is needed'. Let's proceed with a short guide on how to get started.

To get everything working for Qt, GTK-2.0 and GTK-3.0 altogether, we will need the most recent version from the maliit-framework git repository (available here). The latest changes include the merging of meego-inputmethodbridges for GTK+ IM support, as well as new fixes for making GTK+ support work once again. Big thanks to Jon Nordby for finding and fixing the root cause of this issue. Cooperation regarding this bug was magnificent! After fetching, compiling and installing the framework, we will also need the maliit-plugins package installed (most recent sources - here). Detailed instructions on how to build the sources can be found on the Maliit webpage, but in short - basically it's nothing more than just: qmake; make; sudo make install.

Maliit consists of the framework (API and the OSK server etc.) and plugins. Actually, a plugin is the keyboard that we see being displayed on screen. By default, a QML based plugin is built and used, but anyone is free to create their own plugins and use them instead.

How to get Maliit up and running? As noted on the running Maliit section of their web page - after installing both packages, we need to make the application of interest use Maliit as the current input method. Of course, we can do it manually through the "Input method" context menu. Another way is just setting the QT_IM_MODULE (Qt) and GTK_IM_MODULE (GTK+) environment variables. The web-page has a bit outdated information, as currently we should set both of them to Maliit. If needed, we can use pam_env for setting the environment variables for all applications on the system (e.g. the /etc/environment file).

Now we need to make the Maliit OSK server running. Just running maliit-server somewhere in the background is enough, as long as it is started as part of the current session. It is important for the server to be running all the time (for now, because of small problems with GTK+ support - those will be fixed soon), otherwise GTK+ applications will crash (bug report 23949). We can use XDG autostart for starting maliit-server on startup. An exemplary /etc/xdg/autostart/maliit-server.desktop entry could look like this:

  [Desktop Entry]
  Name=Maliit OSK
  Exec=/usr/bin/maliit-server -bypass-wm-hint

For enabling GTK+ support, sadly, we have to perform 2 additional tasks. We need to update both the GTK+ input method module caches. Currently the installation script does not perform this step for us, so we have to do it manually. We have to update two caches - one for GTK-2.0 and one for GTK-3.0. On a Ubuntu-based system (11.10 in my case), this would look like this:

  eval `dpkg-architecture -s` # This is needed to get $DEB_HOST_MULTIARCH
  /usr/bin/gtk-query-immodules-3.0 >/usr/lib/gtk-3.0/3.0.0/immodules.cache
  /usr/bin/gtk-query-immodules-2.0 >/usr/lib/$DEB_HOST_MULTIARCH/gtk-2.0/2.10.0/gtk.immodules

Now, Maliit should be enabled for all GTK+ and Qt applications.

Maliit modified plugin working on Ubuntu 11.10 Unity-2D

Maliit supports keyboard rotation (landscape, portrait) - although it's not really useful for Desktop uses. You can see how it works through the maliit-exampleapp-plainqt example application. Writing custom plugins for the framework is also very pleasant (I might return to this a bit later). I personally use the QML-based quick plugin with a few smaller modifications.

As far as on-screen keyboards go, I prefer Maliit over Onboard or Florence, so I certainly recommend giving it a try. Currently, the GTK+ input method has a bug that might pop-up sometimes, making the plugin invisible until the server is restarted. This should be fixed soon enough, since jonnor and mikhas from Maliit already mentioned a way to hack-fix it. Basing on their propositions, I prepared a small patch as a fix - it's available here. If you encounter a problem with the OSK not re-appearing, apply this patch with patch -p1, rebuild and reinstall. Then, re-run the server with maliit-server -force-show -bypass-wm-hint and it should work. Have fun!
UPDATE! It seems Jon put up a merge request for an almost identical fix to the mainstream! Meaning soon no patching will be required. You can check out the merge request here. Thanks!
UPDATE! Changes adding automatical IM cache update have been added! The Ubuntu cache update during make install patch that I prepared has been merged with the official tree. Jon also added Fedora support as well. Magnificent!