Difference between revisions of "IBus"

From NixOS Wiki
Jump to: navigation, search
(updated to the new version)
(Describe configuration for iBus on GNOME)
 
Line 18: Line 18:
 
{{Evaluate}}
 
{{Evaluate}}
 
After switching, you still need to logout from your session and login again for ibus to work correctly.
 
After switching, you still need to logout from your session and login again for ibus to work correctly.
 +
 +
===== With GNOME =====
 +
 +
For GNOME, you must next enable these languages as input sources. For example,
 +
 +
{{file|/etc/nixos/home.nix|nix|<nowiki>
 +
{
 +
  dconf.settings = {
 +
    "org/gnome/desktop/input-sources" = {
 +
      sources = [
 +
        (lib.hm.gvariant.mkTuple [ "xkb" "us" ])
 +
        (lib.hm.gvariant.mkTuple [ "ibus" "libpinyin" ])
 +
        (lib.hm.gvariant.mkTuple [ "ibus" "mozc-jp" ]) ];
 +
    };
 +
  };
 +
};
 +
</nowiki>}}
 +
 +
It may be more convenient to first manually configure these in the GNOME Settings GUI (Settings > Keyboaord > Input Sources > Add Input Source > ...), then convert them into declarative Nix using <code>dconf dump /org/gnome/desktop/input-sources/</code> and <code>dconf2nix</code>.
  
 
==== Input methods ====
 
==== Input methods ====

Latest revision as of 07:46, 2 August 2025

IBus is a bus for various input methods.

Installation

Enabling IBus is described in the manual. Mainly, it can be done as follows:

Breeze-text-x-plain.png
/etc/nixos/configuration.nix
{pkgs, lib, ...}:
{
 i18n.inputMethod = {
  enable = true;
  type = "ibus";
  ibus.engines = with pkgs.ibus-engines; [ /* any engine you want, for example */ anthy ];
 };
}


After switching, you still need to logout from your session and login again for ibus to work correctly.

With GNOME

For GNOME, you must next enable these languages as input sources. For example,

Breeze-text-x-plain.png
/etc/nixos/home.nix
{
  dconf.settings = {
    "org/gnome/desktop/input-sources" = {
      sources = [
        (lib.hm.gvariant.mkTuple [ "xkb" "us" ])
        (lib.hm.gvariant.mkTuple [ "ibus" "libpinyin" ])
        (lib.hm.gvariant.mkTuple [ "ibus" "mozc-jp" ]) ];
    };
  };
};


It may be more convenient to first manually configure these in the GNOME Settings GUI (Settings > Keyboaord > Input Sources > Add Input Source > ...), then convert them into declarative Nix using dconf dump /org/gnome/desktop/input-sources/ and dconf2nix.

Input methods

To get the list of available engines, you can use the tab completion of nix repl.

$ nix repl
nix-repl> ibus-engines.<Tab>

Custom emojis

Custom emojis can be added to the emoji selection dialog of IBus. This can be used to workaround the fact that GTK does not support compose rules which output more than one unicode codepoint. Here an example Home Manager module:

Breeze-text-x-plain.png
~/.config/nixpkgs/home.nix
{ pkgs, lib, config, ... }:
let
  /* define here the list of desired favorite emoji */
  fav = {
    shrug = ''¯\_(ツ)_/¯'';
    "markdown-shrug" = ''¯\\\_(ツ)\_/¯'';
    flip = ''(╯°□°)╯︵ ┻━┻'';
  };
in
{
  dconf.settings."desktop/ibus/panel/emoji" = with lib.hm.gvariant; {
    favorite-annotations = mkArray type.string (lib.attrNames fav);
    favorites = mkArray type.string (lib.attrValues fav);
  };
}


Then, typing Ctrl+Shift+e and then shrug, Space and Return will insert ¯\_(ツ)_/¯.