$ sudo dpkg-reconfigure keyboard-configuration
When the screen changes, set the keyboard according to the following procedure
Generic 105-key PC (intl.)
→ Japanese
→ Japanese
→ The default for the keyboard layout
→ No compose key
→ Yes
$ sudo apt install ibus-mozc
Then do the following to add the input source (Settnigs
can be opened from Ubuntu search)
Settings
→ Region & Language
→ Input sources +
→ Japanese
→ Japanese (Mozc)
$ sudo vi /usr/share/ibus/component/mozc.xml
Change as follows
<layout>default</layout>
→ <layout>jp</layout>
$ gnome-session-properties
Add
→ setxkbmap jp
→ Save
For Name, put set xkbmap jp
in Command and save it.
If you reboot at the end, you should be able to switch the input source with the Windows key and the space key, and switch between romaji and hiragana with half-width/full-width.