Fcitx-mozc: switching between hiragana and katakana

Hello everyone,

I’m fairly new to Manjaro, and a learner of Japanese. It seems most users type in romaji, but I use direct kana input.

On Windows:

  • pressing Alt + Shift changes the input language (to Japanese, with English characters)
  • Alt + Caps Lock changes the keyboard input to hiragana
  • pressing it again changes to katakana
  • Ctrl + Caps Lock returns to hiragana

(I think these key combos are right, but I’ve been relying on muscle memory for a long time.)

In Mozc settings, I can’t find any key mapping option for changing between the hiragana and katakana “composition modes” (as Mozc calls them). Is there a way to set a key for switching from one to the other?

Note: I’ve tried using xmodmap and setting Caps Lock as the Muhenkan key, but this disables Caps Lock behaviour in other languages as well. Is it possible to set multiple keys to one action? Not as a compose key, which is a succession of inputs, but rather a same-time combination?

Thank you.

Hi,

I learn japanese as well and I have an alternative and completely different solution for you : I never heard of that program, actually I wrote my own python script to directly transcribe romaji to hiragana or katakana, there it is:

import sys as s 
import romkan as r 
ph = s.argv[2:] 
o = " ".join(ph) 
if s.argv[1] == "hiragana": 
    print(r.to_hiragana(o), end = "") 
elif s.argv[1] == "katakana": 
    print(r.to_katakana(o), end = "") 

I use it in 2 different ways : either in the terminal thanks to a function I wrote myself (it’s in fish shell but I can write a bash version if you want) :

function hr ### romaji to hiragana
	set a (python  ~/.tg/jap.py hiragana $argv)
	printf $a | xclip -selection c
	echo \n$a\n
end

then I can type hr omae ha mou shindeiru in my terminal, which outputs おまえ は もう しんでいる and copies it into my clipboard.

The second way is a rofi script, which basically does the same thing but from a GUI, so I simply call it with a key binding. It looks like this:

Which copied マンジャロ into my clipboard

If you’re interested in using this solution I can tell you how to set everything up

EDIT : Or you can try this

Hi oguere,

Thanks for the reply. Truthfully, writing in romaji isn’t really the main problem; I prefer to use direct kana input, where a single key press inserts a specific kana (in hiragana or katakana), rather than a Roman letter.

The script you have here is impressive, but like the GitHub project you’ve linked, its primary focus is romaji.

My main objective is simply to set a hotkey (or key combination) to switch between hiragana and katakana inputs.

All right I misunderstood your problem , but I’m afraid nobody in this forum will be able to help you, since it’s a very specific issue. You might have to post an issue on their github. Also, there is an article on the bible arch wiki about mozc, did you check it ?

Thanks. I had checked that page multiple times, but now, after several attempts, I’ve managed to figure out XModMap, allowing me to set an arbitrary key as the “muhenkan” key, which switches between hiragana, katakana, and also half-width katakana (which I didn’t want but it’s still a better setup than what I have on Windows).

After downloading xorg-xmodmap and xorg-xev, I used xev in Konsole to figure out the keycode for the Pause key (127), using the line provided in the ‘Identifying keycodes in Xorg’ section of the Arch Linux ‘Keyboard input’ page:

xev | awk -F'[ )]+' '/^KeyPress/ { a[NR+2] } NR in a { printf "%-3s %s\n", $5, $8 }'

From there, all I needed to do was open ~/.Xmodmap (which is auto-loaded by the Xmodmap process in ~/.xinitrc) and add this line:

keycode 127 = Muhenkan

then, back in Konsole, reload the bindings with XModMap so I wouldn’t have to restart the computer:

xmodmap ~/.Xmodmap

and everything seems to work now. I press Ctrl + Space to switch to Mozc, for which I’ve set hiragana as the default input, and I hit the Pause key to cycle through katakana and half-width katakana.

Apparently, if the keyboard is unplugged momentarily, the custom key mappings are lost and the user will need to reload them with the command above. But I don’t anticipate that to happen much at all.

So thank you for the advice, I guess it just took some time for me to better learn the tools I needed.

Glad you found out, I didn’t know about xmodmap though

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.