Ubuntu系统中默认使用左Shift切换中英文,由于平时经常使用Shift进行选择操作,经常误切换。
计划作如下修改:
切换中英文:左Shift→右Shift
切换拼音:右Shift→左Control
Ctrl+Alt+T 打开终端,输入以下命令。
xyx@laptop:~$ cd /usr/share/ibus-table/engine/
xyx@laptop:/usr/share/ibus-table/engine$ sudo gedit table.py
修改其中的关键代码。
1、切换中英文(使用右 Shift 键)
def _process_key_event (self, key):
'''Internal method to process key event'''
# Match mode switch hotkey
if (self._editor.is_empty()
and (self._match_hotkey(
key, IBus.KEY_Shift_R,
IBus.ModifierType.SHIFT_MASK))):
self.set_input_mode(int(not self._input_mode))
return True
2、切换拼音(使用左 Control 键)
# Change pinyin mode
# (change only if the editor is empty. When the editor
# is not empty, the right shift key should commit to preëdit
# and not change the pinyin mode).
if (self._ime_py
and self._editor.is_empty()
and self._match_hotkey(
key, IBus.KEY_Control_L,
IBus.ModifierType.CONTROL_MASK)):
self.set_pinyin_mode(not self._editor._py_mode)
return True
# process commit to preedit
if (self._match_hotkey(
key, IBus.KEY_Shift_L,
IBus.ModifierType.SHIFT_MASK)
or self._match_hotkey(
key, IBus.KEY_Shift_R,
IBus.ModifierType.SHIFT_MASK)):
res = self._editor.commit_to_preedit()
self._update_ui()
return res
3、修改完保存并关闭文件,然后重启iBus:
ibus-daemon -r &