@ledsun blog

無味の味は佳境に入らざればすなわち知れず

Windows 11 WSLg キーボードレイアウトを US に設定する

WSLgでRubyMineを動かす - @ledsun blog にてWSLgからRubyMineを起動してみました。 US配列の物理キーボードを使っていますが、日本語配列と認識されて、:が入力出来ませんでした。 キーボード配列をUSに変更します。

正しい方法

my notebookによるとsetxkbmap -layout usコマンドを使うそうです。

ledsun@MSI:~►setxkbmap -layout us

Command 'setxkbmap' not found, but can be installed with:

sudo apt install x11-xkb-utils

インストールされていませんでした。インストールします。

ledsun@MSI:~►sudo apt install x11-xkb-utils
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  x11-xkb-utils
0 upgraded, 1 newly installed, 0 to remove and 36 not upgraded.
Need to get 158 kB of archives.
After this operation, 505 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 x11-xkb-utils amd64 7.7+5 [158 kB]
Fetched 158 kB in 1s (150 kB/s)
Selecting previously unselected package x11-xkb-utils.
(Reading database ... 69128 files and directories currently installed.)
Preparing to unpack .../x11-xkb-utils_7.7+5_amd64.deb ...
Unpacking x11-xkb-utils (7.7+5) ...
Setting up x11-xkb-utils (7.7+5) ...
Processing triggers for man-db (2.9.1-1) ...

再度実行します。

ledsun@MSI:~►setxkbmap -layout us

このあとRubyMineを起動するとキーボード配列がUSになり、:が入力出来るようになりました。 WSLを再起動すると、設定が元に戻ります。

.config/fish/config.fishに次のように書いておきました。

# Set keyboard layout US for WSLg
setxkbmap -layout us

失敗した方法

Ubuntuキーボードレイアウト変更手順 - golangの日記 によるとsudo dpkg-reconfigure keyboard-configurationで設定するそうです。。

ledsun@MSI:~►sudo dpkg-reconfigure keyboard-configuration
[sudo] password for ledsun:
Your console font configuration will be updated the next time your system
boots. If you want to update it now, run 'setupcon' from a virtual console.
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.136ubuntu6.7) ...
update-initramfs: Generating /boot/initrd.img-5.4.0-1003-ibm
W: Couldn't identify type of root file system for fsck hook

残念起動しません。

WSLのキーボードが英語配列になってしまふ - Qiita によると/etc/default/keyboardに、X周りのキーボード配列の設定があるそうです。

ledsun@MSI:~[100]►cat /etc/default/keyboard
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS=""

BACKSPACE="guess"

すでにUS配列です。