linux下把Caps_Lock映射成Ctrl
我用的是debian 7,以前是gnome桌面,系統裡就有改變鍵盤布局的設置。之前gnome 崩了一次,就換成了openbox ,稍微配置了一下也可以很好使用。
但沒在系統裡找到修改鍵盤布局的,於是在網上搜相關的博客
交換ctrl和caps lock
http://www.2cto.com/os/201306/222522.html
裡面.xmodmap文件內容是這樣
[html]
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L
將左ctrl ,caps lock交換了,在使用中我發現caps lock的使用率極低,而且這樣互換後很容易不小心按到左ctrl導致錯誤切換大小寫的問題。
所以我嘗試改了下
[html]
remove Lock = Caps_Lock
remove Control = Control_R
keysym Control_R = Caps_Lock
keysym Caps_Lock = Control_R
add Lock = Caps_Lock
add Control = Control_R
這樣,caps lock 和ctrl就都是ctrl的功能。執行下
[plain]
xmodmap ~/.xmodmap 2>/dev/null
運行下xmodmap 可以看到和改之前沒變化
[html]
shift Shift_L (0x32), Shift_R (0x3e)
lock Caps_Lock(0x42)
control Control_L (0x25), Control_R (0x69)
mod1 Alt_L (0x40), Alt_R (0x6c), Meta_L (0xcd)
mod2 Num_Lock (0x4d)
mod3
mod4 Super_L (0x85), Super_R (0x86), Super_L (0xce), Hyper_L (0xcf)
mod5 ISO_Level3_Shift (0x5c), Mode_switch (0xcb)
可以每次開機都運行一下命令,也可以想上文那裡一樣寫道.bashrc或者其他的配置文件
我用的是openbox 桌面,它有一個autostart 文件,我寫到了這裡面
[html]
#
# These things are run when an Openbox X Session is started.
# You may place a similar script in $HOME/.config/openbox/autostart
# to run user-specific things.
#
# If you want to use GNOME config tools...
#
#if test -x /usr/lib/openbox/gnome-settings-daemon >/dev/null; then
# /usr/lib/openbox/gnome-settings-daemon &
#elif which gnome-settings-daemon >/dev/null; then
# gnome-settings-daemon &
#fi
# If you want to use XFCE config tools...
#
#xfce-mcs-manager &
tint2&
xmodmap ~/.xmodmap 2>/dev/null