ubuntu-键盘映射
原文鏈接
偶然間看到一篇文章,在Linux下互換Capslock和LCtrl(鏈接忘了),然后就有了重新映射一下功能鍵的想法。新的映射如下:
| CapsLock | Control |
| LCtrl | Escape |
| RAlt | Control |
| RCtrl | Caps lock |
下面是ubuntu16.04, gnome3的環(huán)境下設(shè)置鍵映射的方法,使用的是xkb。
用到的命令及工具有:dconf-editor, setxkbmap
編寫(xiě)映射文件
在/usr/share/X11/xkb/symbols目錄下面新建一個(gè)文本文件,不如就叫cus_map,然后往里面寫(xiě)入如下內(nèi)容:
// ralt is capslockpartial modifier_keys xkb_symbols "my_maps" { // 右邊alt當(dāng)control使replace key <RALT> { [ Control_L, Control_L ] };// capslock當(dāng)control使replace key <CAPS> { [ Control_L, Control_L ] };modifier_map Control { <CAPS>, <RALT> };// 左邊control當(dāng)成esckey <LCTL> { [ Escape ] };// 右邊control當(dāng)成capslockreplace key <RCTL> { [ Caps_Lock ] }; }; // end添加到數(shù)據(jù)庫(kù)中
打開(kāi)/usr/share/X11/xkb/rules/evdev文件,找到! option = symbols的行,在下面加入剛剛編寫(xiě)的映射,修改之后如下:
! option = symbolscus_map:rctrl_as_caps = +cus_map(my_maps)grp:shift_toggle = +group(shifts_toggle)altwin:menu = +altwin(menu)altwin:meta_alt = +altwin(meta_alt)...使其對(duì)gnome可見(jiàn)
打開(kāi)/usr/share/X11/xkb/rules/evdev.lst,在! option一欄的后面加上一行:
...esperanto:dvorak To the corresponding key in a Dvorak layoutesperanto:colemak To the corresponding key in a Colemak layoutsolaris Maintain key compatibility with old Solaris keycodessolaris:sun_compat Sun Key compatibilityterminate Key sequence to kill the X serverterminate:ctrl_alt_bksp Ctrl + Alt + Backspacecus_map:my_maps my mappings啟用映射
方法一
使用dconf-editor修改數(shù)據(jù)庫(kù)。
運(yùn)行dconf-editor,找到/org/gnome/desktop/input-sources/xkb-options,這是一個(gè)列表,往里面加入我們的map:['cus_map:my_maps']。
如果之前里面有內(nèi)容,用,分隔字符串即可。
方法二
使用setxkbmap -print查看當(dāng)前的映射情況,如下:
xkb_keymap {xkb_keycodes { include "evdev+aliases(qwerty)" };xkb_types { include "complete" };xkb_compat { include "complete" };xkb_symbols { include "pc+us+cn:2+inet(evdev)+cus_map(rctrl_as_caps)" };xkb_geometry { include "pc(pc105)" }; };然后啟用:
$ setxkbmap -layout cn -option cus_map:my_maps最后
使用setxkbmap -layout <your layout>,如果編寫(xiě)得沒(méi)有錯(cuò)誤,映射生效。
參考文章:
[Custom keymaps in GNOME 3 on Wayland](Custom keymaps in GNOME 3 on Wayland)
總結(jié)
以上是生活随笔為你收集整理的ubuntu-键盘映射的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 【记录】有关parseInt的讨论
- 下一篇: Ubuntu16.04 pip下载安装t