2
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.

ArchLinuxで、EscapeをCapsLockに割り当てる(xmodmap未使用)

Last updated at Posted at 2015-06-15

vimを使う人は、Escapeキーの使用頻度が高いです。
また、一般的にCapsLockを活用している人はいません。

そこで、CapsLockにEscapeを割り当ててしまいましょう。

一般的に使われるのが、
gnome-tweak-toolから変える方法、
xmodmapを使う方法、
などですが、私の環境はそもそもgnomeでないのと、xmodmapではスリープした際やキーボードを取り外した際などに設定がリセットされてしまいます。

そこで今回は、Xorgの設定を変更する方法を使います。

設定

まず、現在使っているキーボードの種類とレイアウトを調べます。
以下のコマンドを実行してください。

$ setxkbmap -print -verbose 10
Setting verbose level to 10
locale is C
Trying to load rules file ./rules/evdev...
Trying to load rules file /usr/share/X11/xkb/rules/evdev...
Success.
Applied rules from evdev:
rules:      evdev
model:      pc105
layout:     us
options:    
Trying to build keymap using the following components:
keycodes:   evdev+aliases(qwerty)
types:      complete
compat:     complete
symbols:    pc+us+inet(evdev)+capslock(swapescape)+capslock(escape)
geometry:   pc(pc105)
xkb_keymap {
	xkb_keycodes  { include "evdev+aliases(qwerty)"	};
	xkb_types     { include "complete"	};
	xkb_compat    { include "complete"	};
	xkb_symbols   { include "pc+us+inet(evdev)+capslock(swapescape)+capslock(escape)"	};
	xkb_geometry  { include "pc(pc105)"	};
};

つらつらと出てきましたが、modellayoutという欄をメモしておいてください。この場合は、pc105usですね。

次に、/etc/X11/xorg.conf.d/10-keyboard.confを作成します。今回はvimを使いますが、nanoなど好きなエディタで構いません。

$ sudo vim /etc/X11/xorg.conf.d/10-keyboard.conf
Section "InputClass"

	Identifier "keyboard"

	MatchIsKeyboard "on"
	Option "XkbLayout" "メモをしたlayout"
	Option "XkbModel"  "メモをしたmodel"
	Option "XkbOptions" "caps:escape"

EndSection

あとは、これを保存して再起動(またはディスプレイマネージャを再起動)をすることで反映されます。

$ systemctl reboot
または
$ sudo systemctl restart ディスプレイマネージャ

CapsLockとEscapeをスワップしたい場合

CapsLockにEscapeを割り当てるのではなく、
CapsLockとEscapeの役割を入れ替えたい場合もあるかと思います。

そのときは、

/etc/X11/xorg.conf.d/10-keyboard.conf
Option"XkbOptions""caps:escape"

caps:escape部分をcaps:swapescapeに変更してみましょう。

2
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
2
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?