Set up an ibus switch
This commit is contained in:
parent
841c5180ba
commit
7dc4a387ef
|
@ -7,7 +7,7 @@ with lib;
|
||||||
package = pkgs.unstable.alacritty;
|
package = pkgs.unstable.alacritty;
|
||||||
|
|
||||||
settings = {
|
settings = {
|
||||||
window.opacity = 0.95;
|
window.opacity = 0.8;
|
||||||
font = {
|
font = {
|
||||||
size = 14.0;
|
size = 14.0;
|
||||||
normal.family = "Fantasque Sans Mono Nerd Font";
|
normal.family = "Fantasque Sans Mono Nerd Font";
|
||||||
|
|
|
@ -31,6 +31,8 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
|
imports = [ ./ibus.nix ];
|
||||||
|
|
||||||
options.programs.my-sway = {
|
options.programs.my-sway = {
|
||||||
enable = mkEnableOption "Enable the sway configuration";
|
enable = mkEnableOption "Enable the sway configuration";
|
||||||
fontSize = mkOption {
|
fontSize = mkOption {
|
||||||
|
|
49
home/modules/programs/my-sway/ibus.nix
Normal file
49
home/modules/programs/my-sway/ibus.nix
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
{ pkgs, config, lib, ... }:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
cfg = config.programs.my-sway;
|
||||||
|
|
||||||
|
# Set up an ibus script
|
||||||
|
ibusNext = (
|
||||||
|
let
|
||||||
|
input-methods = [ "xkb:us::eng" "mozc-jp" "Bamboo" ];
|
||||||
|
next = m:
|
||||||
|
let
|
||||||
|
nextRec = l:
|
||||||
|
if (length l == 1)
|
||||||
|
then head input-methods
|
||||||
|
else if (m == head l)
|
||||||
|
then (head (tail l))
|
||||||
|
else nextRec (tail l);
|
||||||
|
in
|
||||||
|
nextRec input-methods;
|
||||||
|
inputCase = m: ''
|
||||||
|
if test $current = "${m}"
|
||||||
|
${pkgs.libnotify}/bin/notify-send \
|
||||||
|
-a ibus \
|
||||||
|
-u low \
|
||||||
|
-t 3000 \
|
||||||
|
"${next m}" \
|
||||||
|
"Input engine changed"
|
||||||
|
${pkgs.ibus}/bin/ibus engine ${next m}
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
pkgs.writeScriptBin "ibus-next-engine" ''
|
||||||
|
#! ${pkgs.fish}/bin/fish
|
||||||
|
|
||||||
|
set current (${pkgs.ibus}/bin/ibus engine)
|
||||||
|
|
||||||
|
${strings.concatMapStrings inputCase input-methods}
|
||||||
|
''
|
||||||
|
);
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
wayland.windowManager.sway.config.keybindings = mkOptionDefault {
|
||||||
|
"${config.wayland.windowManager.sway.config.modifier}+z" = "exec ${ibusNext}/bin/ibus-next-engine";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue