IBus: Difference between revisions
imported>Symphorien ibus with custom emoji |
Undo revision 17030, kept the changes for reference on older versions of Nix |
||
(5 intermediate revisions by 5 users not shown) | |||
Line 5: | Line 5: | ||
Mainly, it can be done as follows: | Mainly, it can be done as follows: | ||
{{file|/etc/nixos | {{file|/etc/nixos/configuration.nix|nix|<nowiki> | ||
{pkgs, lib, ...} | {pkgs, lib, ...}: | ||
{ | { | ||
i18n.inputMethod = { | i18n.inputMethod = { | ||
enable = true; | |||
type = "ibus"; | |||
ibus.engines = with pkgs.ibus-engines; [ /* any engine you want, for example */ anthy ]; | ibus.engines = with pkgs.ibus-engines; [ /* any engine you want, for example */ anthy ]; | ||
}; | }; | ||
Line 17: | 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. | ||
For nix version older than 24.11, <code>enabled = "ibus";</code> is used instead of <code>enable</code> and <code>type</code> | |||
==== Input methods ==== | ==== Input methods ==== | ||
Line 26: | Line 29: | ||
==== Custom emojis ==== | ==== 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. | 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: | ||
{{file|~/.config/nixpkgs/home.nix|nix|<nowiki> | {{file|~/.config/nixpkgs/home.nix|nix|<nowiki> | ||
{ pkgs, lib, config, ... }: | { pkgs, lib, config, ... }: | ||
Line 40: | Line 36: | ||
fav = { | fav = { | ||
shrug = ''¯\_(ツ)_/¯''; | shrug = ''¯\_(ツ)_/¯''; | ||
"markdown-shrug" = ''¯\\\_(ツ)\_/¯''; | |||
flip = ''(╯°□°)╯︵ ┻━┻''; | flip = ''(╯°□°)╯︵ ┻━┻''; | ||
}; | }; | ||
in | 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); | |||
}; | }; | ||
} | } | ||
</nowiki>}} | |||
</ | Then, typing <code>Ctrl+Shift+e</code> and then <code>shrug</code>, Space and Return will insert <code>¯\_(ツ)_/¯</code>. |
Latest revision as of 01:12, 2 September 2024
IBus is a bus for various input methods.
Installation
Enabling IBus is described in the manual. Mainly, it can be done as follows:
/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.
For nix version older than 24.11, enabled = "ibus";
is used instead of enable
and type
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:
~/.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 ¯\_(ツ)_/¯
.