用意
ディレクトリ作成
$ 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.