1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ubuntu18.04+英字配列で日本語入力の切替を左右altで行う+caps lockを左ctrlと入れ替え

Last updated at Posted at 2019-10-05

用意

ディレクトリ作成

$ mkdir -p ~/.xkb/keymap ~/.xkb/symbols

現状設定書き出し

$ setxkbmap -print > ~/.xkb/keymap/mykbd

~/.xkb/symbols/myswap作成

partial modifier_keys
xkb_symbols "myswapkeys" {
  replace key <LCTL> { [ Caps_Lock ] };
  replace key <CAPS> { [ Control_L] };
  key <LALT>  { [ Hiragana ] };
  key <RALT>  { [ Katakana ] };
};

~/.xkb/keymap/mykbdのxkb_symbolsのincludeにmyswap(myswapkeys)追加

xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete" };
    xkb_compat    { include "complete" };
#    xkb_symbols   { include "pc+us+us:2+inet(evdev)+ctrl(swap_lwin_lctl)+myswap(myswapkeys)" };
    xkb_symbols   { include "pc+us+us:2+inet(evdev)+myswap(myswapkeys)" };
    xkb_geometry  { include "pc(pc105)" };
};

+ctrl(swap_lwin_lctl)はalt単体で推したときに問題にならないようにするためのworkaround

システム反映

.bashrcに追記

xkbcomp -I$HOME/.xkb ~/.xkb/keymap/mykbd $DISPLAY 2> /dev/null

~/.xkb/symbols/myswapをコピー

sudo cp -i ~/.xkb/symbols/myswap /usr/share/X11/xkb/symbols/

/usr/share/X11/xkb/rules/evdev に追記

mysetting:myswapkeys = +myswap(myswapkeys)

gnomeのシステム設定に反映

$ export GIO_EXTRA_MODULES=/usr/lib/x86_64-linux-gnu/gio/modules/ # workaround for the issue* 
$ gsettings set org.gnome.desktop.input-sources xkb-options "['mysetting:myswapkeys']"

the issue*

$ gsettings set org.gnome.desktop.input-sources xkb-options "['mysetting:myswapkeys']"
GLib-GIO-Message: 02:13:03.500: Using the 'memory' GSettings backend.  Your settings will not be saved or shared with other applications.

再起動

設定保持確認

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?