ubuntu中除了使用界面修改键盘快捷键外,还可以使用命令行修改键盘快捷键.
一种方式为使用gsettings修改键盘快捷键.
1. 在目录/usr/share/gnome-control-center/keybindings中,可以找到一组xml配置文件
2. 该文件包含一组节点, 该节点与界面操作键盘快捷键(system settings-> keyboard->shortcuts)一一对应.
?xml version="1.0" encoding="UTF-8"?>
<KeyListEntries wm_name="Compiz" schema="org.gnome.desktop.wm.keybindings" package="compiz" group="system" name="Windows">
<KeyListEntry name="activate-window-menu" description="Activate the window menu"></KeyListEntry>
<KeyListEntry name="toggle-fullscreen" description="Toggle fullscreen mode"></KeyListEntry>
<KeyListEntry name="toggle-maximized" description="Toggle maximization state"></KeyListEntry>
<KeyListEntry name="maximize" description="Maximize window"></KeyListEntry>
<KeyListEntry name="unmaximize" description="Restore window"></KeyListEntry>
<KeyListEntry name="toggle-shaded" description="Toggle shaded state"></KeyListEntry>
<KeyListEntry name="close" description="Close window"></KeyListEntry>
<KeyListEntry name="minimize" description="Minimize window"></KeyListEntry>
<KeyListEntry name="begin-move" description="Move window"></KeyListEntry>
<KeyListEntry name="begin-resize" description="Resize window"></KeyListEntry>
<KeyListEntry name="raise" description="Raise window above other windows"></KeyListEntry>
<KeyListEntry name="lower" description="Lower window below other windows"></KeyListEntry>
<KeyListEntry name="maximize-vertically" description="Maximize window vertically"></KeyListEntry>
<KeyListEntry name="maximize-horizontally" description="Maximize window horizontally"></KeyListEntry>
</KeyListEntries>
3. 使用gsettings设置Alt-F4不关闭界面.
gsettings list-keys org.gnome.desktop.wm.keybindings
罗列出所有按键
4. 获取"close"关闭界面的快捷键.
gsettings get org.gnome.desktop.wm.keybindings close
5. 设置"close"关闭界面快捷键.
gsettings set org.gnome.desktop.wm.keybindings close "[]"
此时Alt-F4将不起效果.
6. 如果想恢复默认快捷键.
gsettings reset org.gnome.desktop.wm.keybindings close
此时Alt-F4将关闭快捷键.