Skip to content

Make Japanese input work out of the box (JIS defaults + omarchy setup japanese) - #13327

Closed
lef237 wants to merge 18 commits into
omacom:quattrofrom
lef237:easy-to-use-in-japanese-for-jis
Closed

lef237 wants to merge 18 commits into
omacom:quattrofrom
lef237:easy-to-use-in-japanese-for-jis

Conversation

@lef237

@lef237 lef237 commented Sep 26, 2026 •

Copy link
Copy Markdown

Getting a comfortable Japanese setup on Omarchy today means following a long blog post: install Mozc, hand-edit fcitx5, fix zoom on JIS keyboards, and so on. This turns that into defaults plus one command, so Japanese users get the same omakase setup everyone else does.

ThinkPad E595 with a JIS keyboard running Omarchy

The ThinkPad E595 (JIS) this was tested on. Muhenkan and Henkan sit on either side of the space bar, and Zenkaku/Hankaku is at the top left.

What changes

Automatic, only when the installed layout is Japanese (XKBLAYOUT=jp):

  • Ctrl + Shift + ; (the + key on JIS) zooms in. Apps see Ctrl + Shift + semicolon and ignore it today, so it's forwarded as Ctrl + KP_Add (Ctrl + ^ for Obsidian).
  • In terminals, Ctrl + Space (the tmux/Herdr prefix) switches Mozc back to direct input first, so the key after the prefix reaches the multiplexer instead of Mozc's composition. This only kicks in once Ctrl + Space is no longer an fcitx5 toggle key (which omarchy setup japanese takes care of), so it never undoes a toggle.

omarchy setup japanese (also under Setup > Japanese):

  • Installs fcitx5-mozc and fcitx5-configtool and adds Mozc after the keyboard layout from /etc/vconsole.conf (the same source Hyprland reads). fcitx5's own single-keyboard profile takes that layout; a profile with other input methods keeps them and gets Mozc added after them. One that already has Mozc is left alone.
  • On JIS keyboards: Henkan turns input on, Muhenkan turns it off, and Zenkaku/Hankaku toggles. The toggle lists are replaced, so Ctrl + Space stays free for tmux/Herdr (and Hangul goes too).
  • Sets the GTK interface font to Noto Sans CJK JP at the current size, so kanji use their Japanese forms.
  • Asks before switching the system language to ja_JP.UTF-8. Typing Japanese doesn't require a Japanese desktop.

Deliberately left out

  • CapsLock → Ctrl: it would take away the compose key.
  • --force-device-scale-factor=1 for the Mozc candidate window position in Chromium/Obsidian: it renders those apps at 1x on scaled displays. It's documented as an opt-in workaround in the manual instead.

Testing

  • New test/shell.d/setup-japanese-test.sh and test/shell.d/hyprland-jis-bindings-test.sh (runs the JIS bind callbacks against a fake hl). JIS cases were added to the keyboard layout and binding conflict tests.
  • Verified on a ThinkPad with a JIS keyboard via omarchy dev link: Mozc install and profile, Henkan/Muhenkan switching, fcitx5 settings surviving a restart, Ctrl + Space in tmux/Herdr with Japanese input on, + zoom in Chromium/Obsidian, the interface font, and the locale switch.

Each commit is one step, so it should read well commit by commit.


The setup follows @simosako's write-up (https://portablecode.info/2026/08/19/omarchy-quattro-jp-environment-setup/), and the JIS zoom binding is adapted from their gist (https://gist.github.com/simosako/6bec392d00d13abbda00304f5242abe7). Thanks for figuring all of this out!

Omarchy has made Linux a real joy for a lot of us here in Japan. 🇯🇵

Thank you from Tokyo! 🗼 ありがとうございます! 🙏

@llstrk

llstrk commented Sep 27, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Verified: at 2d81b16, the JIS gating, the keys both Hyprland binds send, and most of omarchy setup japanese behave as described in isolated tests and against upstream source. One input-parsing issue can leave some machines with Mozc as the only input method. The other notes concern existing profiles, the Ctrl + Space bind on JIS installs that keep the fcitx5 default toggle, and documentation wording.

Verified (sandboxed runs and source reading):

  • keyboard.jis() loads both binds for jp, "jp" and jp,us (the last through the PR's own test), and none for us or us,jp. input.lua behaves as before (all existing layout assertions pass).
  • Zoom bind: Chromium, foot and windows without a class get Ctrl + KP_Add; obsidian and md.obsidian.Obsidian get Ctrl + ^. The terminal-prefix bind runs fcitx5-remote -c only in windows tagged terminal, and it is non-consuming, so Hyprland still passes the key on (fcitx5 sees it first, see the Ctrl + Space section below). Hyprland 0.56.2 supports every API these binds use.
  • Henkan, Muhenkan and Zenkaku_Hankaku are valid fcitx5 key names, and the profile sections match fcitx5's format. Stopping the unit before the edit is sound, because fcitx5 saves its profile on exit.
  • On a realistic fcitx5 config, the JIS run replaces only the three hotkey lists, and a second run leaves the file byte-identical. localectl set-locale keeps existing LC_* overrides. omarchy-display-text-size still reads the size from the new font name.
  • The PR's tests pass at the head. The full test/shell.d suite has the same 11 failing files on the head and the merge-base, so none come from this PR, and the new test file passes.

X11 Layout: (unset) produces a keyboard-(unset) input method

x11_setting falls back to us only when the value is empty (line 93). When localed has no X11 layout, systemd's localectl status does not print an empty value. It prints (unset): localectl.c sets the table's ersatz string to TABLE_ERSATZ_UNSET, and bus-map-properties.c maps an empty string to NULL.

localectl status (stub, systemd's format):   X11 Layout: (unset)
  -> layout="(unset)"                        (not empty, so no fallback to us)
  -> profile: Default Layout=(unset)
              Name=keyboard-(unset)
  -> output:  "Added Mozc after keyboard-(unset) in your input methods."
control (X11 Layout: us)                  -> Name=keyboard-us

In a sandbox run, a localectl stub printed systemd's (unset) line and the script produced the lines above. The fcitx5 behaviour below comes from source and was not run: on load, fcitx5 removes an item with no registered input method (inputmethodmanager.cpp, "is not valid. Removed."), so the group keeps only Mozc.

Impact: on machines where localed has no X11 layout, the group has no keyboard-layout entry to switch back to, so fcitx5's toggle hotkeys have nothing to switch to. Omarchy's own code treats a missing XKBLAYOUT as a real state (input.lua falls back to us, and a migration notes that vconsole.conf only guarantees KEYMAP). Fresh installs through systemd-firstboot --keymap write XKBLAYOUT when systemd can map the keymap to an X11 layout (it maps us and jp106), so this mostly affects older or hand-configured installs.

Suggested change: read XKBLAYOUT/XKBVARIANT from /etc/vconsole.conf, as default/hypr/keyboard.lua does. That also keeps the script and the Hyprland binds on one source; today they can disagree when only xorg.conf.d sets a layout. The smaller fix is to treat (unset) as empty. A stub case that prints (unset) would cover it.

An existing profile without Mozc is replaced, not extended

When ~/.config/fcitx5/profile has no Mozc, the script backs it up and writes a new one-group profile. In a sandbox run, a profile with keyboard-us and pinyin ended up with keyboard-us and mozc, plus profile.bak.<epoch> next to it. The script only prints Added Mozc after keyboard-us in your input methods., and the manual says the command "adds Mozc after your keyboard layout". The PR description is accurate ("backed up first"), but the text users see is not.

Impact: users who already type Chinese, Korean or another language through fcitx5 lose that input method and are not told a backup exists. For a profile fcitx5 generated with a single keyboard, nothing is lost.

Suggested change: append Mozc to the existing group when it is missing, or print that the previous input methods were replaced and where the backup is, and say so in the manual.

On JIS, the terminal Ctrl + Space bind competes with the fcitx5 default toggle

The prefix bind is active on every JIS install, whether or not omarchy setup japanese has run. fcitx5's default TriggerKeys include Control+space, and the manual's existing paragraph tells users to add an engine with fcitx5-configtool, which keeps that default unless they pick another key. From source, not a live session:

Ctrl + Space in a terminal (JIS, default fcitx5 hotkeys, Mozc added)
  Hyprland: bind matches -> spawns `fcitx5-remote -c` (async) -> key passed on
  fcitx5:   Control+space is a trigger key -> toggles the input method
  also:     Deactivate runs on the same input context
  result:   one toggle direction is undone in terminals (the order was not timed)

Impact: for JIS users who added Mozc (or another input method) themselves or through another route and kept Ctrl + Space as the toggle, it stops toggling reliably in terminals. Zenkaku/Hankaku still works, and other windows are unaffected. Users who run the new command are not affected, because it removes Ctrl + Space from the toggle.

Suggested change: state in the manual that on JIS the terminal-prefix behaviour assumes Ctrl + Space is not the fcitx5 toggle (run omarchy setup japanese, or remove it in fcitx5-configtool). Alternatively, skip fcitx5-remote -c while Control+space is still a trigger key.

Documentation notes:

  • resetStateWhenFocusIn defaults to No in every sampled fcitx5 release that has the option (5.1.9 through 5.1.23; the sampled releases up to 5.1.7 don't have it), and only All and Program reset state on focus. The comment at line 180 ("The default resets every window") and the manual's "keeps Japanese input on when you switch between windows" therefore don't describe a change for default configs. If input was seen dropping on window switches with a default config, the cause is elsewhere.
  • The manual's JIS table lists Henkan and Muhenkan as defaults that apply to JIS installs, but they only take effect after the command runs. The zoom and terminal-prefix rows are automatic, and Zenkaku/Hankaku already toggles through fcitx5's default hotkeys.
  • The jis.lua comment says "the terminals all" zoom on Ctrl + KP_Add. kitty's default zoom key is ctrl+shift+kp_add. kitty also did not zoom on JIS Ctrl + Shift + ; before this PR, so this is wording, not a regression.
  • On JIS the three hotkey lists are replaced entirely, so any other toggle keys (for example fcitx5's default Hangul) are removed along with Ctrl + Space.

Optional test improvement: no test calls the jis.lua callbacks. Diagnostic mutants that drop non_consuming (which would swallow the prefix), run fcitx5-remote -c in every window, send KP_Subtract instead of KP_Add, or delete the Obsidian override all pass both Lua tests. A test that runs the two callbacks with a fake hl would catch them. Likewise, "fcitx5 is down while its profile is rewritten" only compares the order of the stop and start calls, and a mutant that stops fcitx5 after writing the profile still passes. Having the systemctl stub snapshot the profile at stop and at start would pin the ordering.

Related open PRs: #9634 adds a separate one-step Mozc setup (omarchy-setup-input-mozc) with its own menu entry and rewrites the same fcitx5 paragraph in the manual. #11719 (Hangul) and #12312 (Traditional Chinese) use the omarchy-setup-input-<engine> naming; all three put their entries under a Setup > Input Method submenu, while this PR adds Japanese directly under Setup. #12920 also writes ~/.config/fcitx5/profile.


Review information

Test scope: Source review of the pinned head against its merge-base, plus upstream Hyprland 0.56.2, fcitx5 (5.1.23 and sampled older releases), systemd v261, Mozc and kitty source. The PR's tests, the full test/shell.d suite, a callback harness for jis.lua, setup-script scenarios with every system command stubbed, and diagnostic mutants ran in an isolated sandbox. No live Hyprland, fcitx5 or Mozc session and no real key events were used, so key-delivery order and timing come from source. test/cli stops early in the sandbox (same on both sides), so the new command's CLI metadata was checked by reading it.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@lef237

lef237 commented Sep 27, 2026

Copy link
Copy Markdown
Author

Thanks for the thorough review! Pushed fixes as separate commits:

  • (unset) layout: the command now reads XKBLAYOUT/XKBVARIANT from /etc/vconsole.conf, like default/hypr/keyboard.lua, and falls back to us when there's no layout (8cab458).
  • Existing profile replaced: Mozc is now appended to the existing group, keeping the input methods already there. Only a profile with no group is replaced, and the command prints where the backup went (6f704cc).
  • Ctrl + Space on JIS: the terminal-prefix bind now skips fcitx5-remote -c while Control+space is still an fcitx5 trigger key, or while there's no trigger list (fcitx5's default), so it never undoes a toggle (7b40f94).
  • resetStateWhenFocusIn: you're right that No is already the default, so the setting is gone, along with the manual's claim (929fabf).
  • Docs: the manual now says Henkan/Muhenkan apply after the command runs and that other toggle keys like Hangul are replaced too. The kitty wording in jis.lua is fixed (03b18a5).
  • Tests: added hyprland-jis-bindings-test.sh, which runs the bind callbacks against a fake hl, and the systemctl stub now records the profile at stop and start. The mutants you listed all fail now (7b40f94, e8bd442).

On the related PRs: this command sets more than the input method (locale and interface font too), so I kept it as omarchy setup japanese rather than omarchy-setup-input-mozc. Happy to adjust if maintainers prefer the Setup > Input Method layout.

@omarchybot omarchybot added the enhancement New feature or request label Sep 27, 2026
@llstrk

llstrk commented Sep 29, 2026

Copy link
Copy Markdown

Automated AI review

Community review: Independent automated community review, unaffiliated with the Omarchy team, intended to help prepare PRs for their review.

Outcome: At 03b18a5, on JIS Mozc usually joins fcitx5's keyboard-us group; all points from the earlier review are resolved, as the reply says.

On JIS, the vconsole layout usually no longer reaches the fcitx5 profile

fcitx5 saves its profile when stop_fcitx5 stops it, usually the stock single keyboard-us group, and the new append path keeps it. A JIS install then gets keyboard-us + mozc with Default Layout=us, where 2d81b16 wrote keyboard-jp. Impact (fcitx5-mozc source, not run live): Mozc picks its kana table from the group layout, so kana input (かな入力) uses the US table; romaji should be unaffected.

Suggested change: when the group holds a single keyboard-* entry, write the vconsole-layout group as 2d81b16 did.

Reproducer (fails at 03b18a5, passes at 2d81b16)

The systemctl stub models fcitx5 saving its stock profile on stop. Save as test/shell.d/setup-japanese-stock-profile-test.sh and run bash test/shell.d/setup-japanese-stock-profile-test.sh from the repository root.

#!/bin/bash

# fcitx5 writes its in-memory profile when it exits (Instance's exit event calls
# save(), and SIGTERM from `systemctl --user stop` triggers it). On a session
# where fcitx5 is running, stop_fcitx5 therefore leaves fcitx5's own profile on
# disk before setup_input_method looks at it. Without customisation that is the
# stock single keyboard-us group fcitx5 builds when it cannot read an X11 layout.
# This stubs systemctl to do the same, then runs the command on a JIS layout.

set -euo pipefail

source "$(dirname "$0")/base-test.sh"

test_dir=$(mktemp -d)
trap 'rm -rf "$test_dir"' EXIT

stub_bin="$test_dir/bin"
mkdir -p "$stub_bin"

cat >"$stub_bin/systemctl" <<'STUB'
#!/bin/bash
profile="$HOME/.config/fcitx5/profile"
if [[ $* == "--user stop omarchy-fcitx5.service" && ! -f $profile ]]; then
  mkdir -p "${profile%/*}"
  cat >"$profile" <<'EOF'
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=keyboard-us

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[GroupOrder]
0=Default
EOF
fi
STUB
# The same JIS layout for heads that read it from localectl instead.
cat >"$stub_bin/localectl" <<'STUB'
#!/bin/bash
echo "   System Locale: LANG=en_US.UTF-8"
echo "      X11 Layout: jp"
STUB
for cmd in omarchy-pkg-add pkill sudo gsettings; do
  printf '#!/bin/bash\nexit 0\n' >"$stub_bin/$cmd"
done
printf '#!/bin/bash\nexit 1\n' >"$stub_bin/gum"
chmod +x "$stub_bin"/*

home="$test_dir/home"
mkdir -p "$home"
printf 'KEYMAP=jp106\nXKBLAYOUT=jp\n' >"$test_dir/vconsole.conf"

HOME="$home" PATH="$stub_bin:$PATH" OMARCHY_VCONSOLE_PATH="$test_dir/vconsole.conf" \
  bash "$ROOT/bin/omarchy-setup-japanese" >"$test_dir/out" 2>&1 ||
  fail "setup japanese runs" "$(<"$test_dir/out")"

profile=$(<"$home/.config/fcitx5/profile")
printf -- '--- command output ---\n%s\n--- resulting profile ---\n%s\n---\n' "$(<"$test_dir/out")" "$profile"

grep -Fx 'Default Layout=jp' <<<"$profile" >/dev/null &&
  grep -Fx 'Name=keyboard-jp' <<<"$profile" >/dev/null &&
  grep -Fx 'Name=mozc' <<<"$profile" >/dev/null ||
  fail "a JIS keyboard gets Mozc after keyboard-jp when fcitx5 saved its stock profile on stop"
pass "a JIS keyboard gets Mozc after keyboard-jp when fcitx5 saved its stock profile on stop"

Actual output at 03b18a5 (exit 1):

--- command output ---
Installing Mozc...
Added Mozc after your other input methods.


Japanese input is ready. Turn it on with Henkan and off with Muhenkan.
Change input methods and hotkeys with fcitx5-configtool.
--- resulting profile ---
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=us
# Default Input Method
DefaultIM=keyboard-us

[Groups/0/Items/0]
# Name
Name=keyboard-us
# Layout
Layout=

[GroupOrder]
0=Default

[Groups/0/Items/1]
# Name
Name=mozc
# Layout
Layout=
---
not ok - a JIS keyboard gets Mozc after keyboard-jp when fcitx5 saved its stock profile on stop

Actual output at 2d81b16 (exit 0):

--- command output ---
Installing Mozc...
Added Mozc after keyboard-jp in your input methods.


Japanese input is ready. Turn it on with Henkan and off with Muhenkan.
Change input methods and hotkeys with fcitx5-configtool.
--- resulting profile ---
[Groups/0]
# Group Name
Name=Default
# Layout
Default Layout=jp
# Default Input Method
DefaultIM=mozc

[Groups/0/Items/0]
# Name
Name=keyboard-jp
# Layout
Layout=

[Groups/0/Items/1]
# Name
Name=mozc
# Layout
Layout=

[GroupOrder]
0=Default
---
ok - a JIS keyboard gets Mozc after keyboard-jp when fcitx5 saved its stock profile on stop
Details

Mechanism (fcitx5 5.1.23 source): SIGTERM from systemctl --user stop makes fcitx5 exit, and its exit handler calls save(), which writes profile (instance.cpp, inputmethodmanager.cpp). Without X11 rule names, fcitx5's default group uses us (buildDefaultGroup). fcitx5-mozc derives its JIS flag from the group layout (mozc_engine.cc) and picks kKanaJpMap or kKanaUsMap from it (fcitx_key_translator.cc). The PR's JIS test starts without a profile, which the real flow does not normally produce after stop, so it passes. A user whose fcitx5 group layout is already jp is not affected.

Verified (sandbox runs and source):

  • A missing vconsole.conf or one with only KEYMAP gives keyboard-us, and jp,us keeps only jp.
  • A profile with other input methods keeps them and gains Mozc; a group-less profile is replaced and the backup path is printed.
  • The prefix bind skips fcitx5-remote -c without a config, with fcitx5's default trigger keys (written out, or commented out as fcitx5 5.1.22+ saves them) and while Control+space is listed. It runs -c once the command has written its own trigger keys.
  • The four PR test files pass, and all five mutants from the earlier review now fail.
  • default/omarchy/omarchy-menu.jsonc merges cleanly with the current quattro.

Optional notes:

  • Documentation: the manual says Ctrl + Space "switches to direct input before the prefix goes through". From Hyprland and fcitx5 source (not timed), the press normally reaches fcitx5 before fcitx5-remote -c; nothing orders the two. With nothing being composed, Mozc passes it on and the next key is likely direct. While composing, Mozc takes Ctrl + Space itself, so the prefix is lost and the pending text is committed. A note to confirm composition first would match.
  • Test: a mutant that starts fcitx5 before writing the JIS hotkey lists still passes. fcitx5 reads its config at start, so the new keys would only apply after fcitx5 restarts or reloads its config. Having the systemctl stub also record the config at start would catch it.

Related open PRs:


Review information

Test scope: Source and sandbox tests at 03b18a5; no live Hyprland, fcitx5 or Mozc session.

AI process: Opus 5.5 Medium coordination and synthesis, Opus 5.5 Xhigh technical review and final fact check, GPT 6 Sol Xhigh search for related issues, Opus 5.5 Medium editorial check.

Opt out: To stop receiving these reviews, reply to this comment saying so.

@lef237

lef237 commented Sep 29, 2026

Copy link
Copy Markdown
Author

Thanks, good catch! That was a regression from my append change. Fixed in separate commits:

  • fcitx5's own profile on JIS: a profile that holds only a single keyboard layout (what fcitx5 saves on stop when nobody picked input methods) is now written fresh with the layout from vconsole.conf, so JIS gets keyboard-jp and Mozc's kana table matches. Profiles with other input methods still get Mozc appended. Your reproducer passes now, and a test covers the stock profile (3435891).
  • Composing: the manual now says to confirm or cancel composition before pressing Ctrl + Space, since Mozc keeps it while composing (e4498d7).
  • Test: the systemctl stub also records the JIS hotkeys at start, so starting fcitx5 before writing them fails now (9dfb6eb).

@jandrusk

jandrusk commented Oct 8, 2026

Copy link
Copy Markdown

This now conflicts with quattro and needs a rebase. While you're at it, there's related work to line up with: #14114 (docs for Mozc setup after a JIS install, for #14112) and #12920 (seeding the fcitx5 DefaultIM from vconsole.conf) both touch the same first-run story. It would be good to make sure omarchy setup japanese and the docs say the same thing.

@lef237

lef237 commented Oct 9, 2026

Copy link
Copy Markdown
Author

Thanks for the pointers! It looks like this PR and #12920 are being consolidated in #14433, so I'll leave this one as is for now and rebase if it's still needed.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this. What it does is now on quattro, so I am closing it.

This is now on quattro: #14433 brought the JIS bindings, Henkan/Muhenkan/Zenkaku handling, a keyboard-jp profile and the Japanese glyph fallback, and Setup > Language (#15326) sets a Japanese session. #14433 consolidated this pull request, and #15508 adds the remaining JIS piece, naming the resize keys correctly in the keybindings menu (#10452).

This was checked against quattro by Claude, with Codex at medium effort verifying the claims above. If something here is still missing, say so and this can be reopened.

@omarchybot omarchybot closed this Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants