如何使键盘像 OSX System Wide 一样工作?

如何使键盘像 OSX System Wide 一样工作?

我经常在两台计算机之间切换:

  • OSX 雪豹
  • Ubuntu 10.10

我希望能够让 Ubuntu 使用与 OSX 相同的键盘快捷键系统范围,仅适用于以下键盘序列(即我不想让 Ctrl 像 Super 一样)

  • Super+C-> 复制

  • Super+V-> 粘贴

  • Super+T-> 无论我使用的是什么浏览器,都打开一个新标签。

  • Super+W-> 关闭我所使用的浏览器中的标签。

简而言之,我有什么办法可以绘制地图吗?只是这些键盘序列到以下内容,系统范围?

  • Super+C->Ctrl+C
  • Super+V->Ctrl+V
  • Super+T->Ctrl+T
  • Super+W->Ctrl+W

我知道有办法在 vim 和 Firefox 上做到这一点,而且我确信对于大多数应用程序来说尤其如此……但我更愿意只做一次,让它以这种方式工作系统范围

我在 Ubuntu 上使用标准 PC 键盘,即“通用 105 键(国际)PC”。我在 Mac mini 上也使用相同的键盘。

答案1

如果你安装了该xautomation包,你可以在系统 →优先键盘快捷键风俗喜欢:

xte "keyup Meta_L" "keyup Meta_R" "keyup c" "keydown Control_L" "key c" "keyup Control_L"

并将其映射到Meta+ C

您可能需要"keyup Super_L" "keyup Super_R"根据您的键盘使用。


替代解决方案:

安装 AutoKey ( apt-get install autokey-gtk) 并将短语设置为:

Phrase Text: <ctrl>+C (actually type out the <ctrl>+ here)
Paste Using: Keyboard
Abbreviation: None
Hotkey: <super>+v
Window Filter: None

答案2

从 Ubuntu 14 开始,你可以使用GNOME 调整

sudo apt install gnome-tweaks # formerly gnome-tweak-tool

然后,查找调整工具 > 键盘和鼠标 > 其他布局选项 > Alt/Win 键行为。

并检查:Ctrl 映射到 Win 键和常用的 Ctrl 键。

截屏

答案3

有一种方法可以映射CtrlWin/Super键:

  1. 系统->偏好设置->键盘

  2. 打开标签布局

  3. 点击选项...

  4. 打开Alt/Win关键行为

  5. 并选择控制映射到 Win 键

对于控制台,有一个论坛帖子如何做到这一点这里

欲了解更多信息,请查看 Linux 通用键盘操作指南这里

问候

答案4

撞这个!你的小指会感谢我

全部我的肌肉记忆是基于 Mac 的,我在工作和个人生活中都使用 Mac,但我偶然发现了一个戴尔 Latitude E7470我觉得我也可以尝试一下 Linux(因为我的 Macbook Pro 是 2012 年的,很重,我不想再费心了)\r\n我使用了许多不同的语言(例如,用英语或中文拼写)来表达自己的意思。因此,我一直在慢慢研究如何修改系统以适应我的肌肉记忆,而不是重新学习键盘快捷键。

起初,我只是使用键盘 > 布局 > 选项... 设置“Ctrl 映射到 Alt;Alt 映射到 Win”但是,这是一件非常小的事情,我不喜欢我的设置直到我通过了欢迎界面。我还无法让 ~/.Xmodmap 在启动时运行(无论是单独运行,还是作为 .xinitrc 的一部分,还是作为启动应用程序中的自定义启动命令以及 /etc/default/

我目前正在跑步Ubuntu MATE 19.10(Eoan),并且键盘被识别为pc105

您必须修改下面的脚本(或单个文件,如果您已经对它们进行了其他想要保留的修改)以匹配您的计算机所具有的键盘。

制作〜/.Xmodmap:

echo '! -*- coding: utf-8 -*-
! keycode  37 = Control_L NoSymbol Control_L
! keycode  64 = Alt_L Meta_L Alt_L Meta_L
! keycode 105 = Control_R NoSymbol Control_R
! keycode 108 = Alt_R Meta_R Alt_R Meta_R
! keycode 133 = Super_L NoSymbol Super_L
! keycode 134 = Super_R NoSymbol Super_R
! keycode 135 = Menu NoSymbol Menu
! keycode 147 = XF86MenuKB NoSymbol XF86MenuKB
! keycode 204 = NoSymbol Alt_L NoSymbol Alt_L
! keycode 206 = NoSymbol Super_L NoSymbol Super_L
!
! keycode 105 = Alt_R Meta_R
clear control
clear mod1
clear mod4
keycode 37 = Super_L
keycode 105 = Super_R
keycode 133 = Alt_L Meta_L
keycode 64 = Control_L
keycode 108 = Control_R
add control = Control_L Control_R
add mod1 = Alt_L Meta_L
add mod4 = Super_L Super_R' > ~/.Xmodmap

制作〜/.xinitrc:

echo 'if [ -s ~/.Xmodmap ]; then
    xmodmap ~/.Xmodmap
fi
xmodmap ~/.Xmodmap' > ~/.xinitrc

修改您的键盘的 X11 键盘符号文件(这里重要的部分是include "altwin(ctrl_alt_win)"之前的// End of modifier mappings.这个是未经修改的 /usr/share/X11/xkb/symbols/pc 文件):

echo 'default  partial alphanumeric_keys modifier_keys
xkb_symbols "pc105" {

    key <ESC>  {    [ Escape        ]   };

    // The extra key on many European keyboards:
    key <LSGT> {    [ less, greater, bar, brokenbar ] };

    // The following keys are common to all layouts.
    key <BKSL> {    [ backslash,    bar ]   };
    key <SPCE> {    [    space      ]   };

    include "srvr_ctrl(fkey2vt)"
    include "pc(editing)"
    include "keypad(x11)"

    key <BKSP> {    [ BackSpace, BackSpace  ]   };

    key  <TAB> {    [ Tab,  ISO_Left_Tab    ]   };
    key <RTRN> {    [ Return        ]   };

    key <CAPS> {    [ Caps_Lock     ]   };
    key <NMLK> {    [ Num_Lock      ]   };

    key <LFSH> {    [ Shift_L       ]   };
    key <LCTL> {    [ Control_L     ]   };
    key <LWIN> {    [ Super_L       ]   };

    key <RTSH> {    [ Shift_R       ]   };
    key <RCTL> {    [ Control_R     ]   };
    key <RWIN> {    [ Super_R       ]   };
    key <MENU> {    [ Menu          ]   };

    // Beginning of modifier mappings.
    modifier_map Shift  { Shift_L, Shift_R };
    modifier_map Lock   { Caps_Lock };
    modifier_map Control{ Control_L, Control_R };
    modifier_map Mod2   { Num_Lock };
    modifier_map Mod4   { Super_L, Super_R };

    // Fake keys for virtual<->real modifiers mapping:
    key <LVL3> {    [ ISO_Level3_Shift  ]   };
    key <MDSW> {    [ Mode_switch       ]   };
    modifier_map Mod5   { <LVL3>, <MDSW> };

    key <ALT>  {    [ NoSymbol, Alt_L   ]   };
    include "altwin(meta_alt)"

    key <META> {    [ NoSymbol, Meta_L  ]   };
    modifier_map Mod1   { <META> };

    key <SUPR> {    [ NoSymbol, Super_L ]   };
    modifier_map Mod4   { <SUPR> };

    key <HYPR> {    [ NoSymbol, Hyper_L ]   };
    modifier_map Mod4   { <HYPR> };
    include "altwin(ctrl_alt_win)"
    // End of modifier mappings.

    key <OUTP> { [ XF86Display ] };
    key <KITG> { [ XF86KbdLightOnOff ] };
    key <KIDN> { [ XF86KbdBrightnessDown ] };
    key <KIUP> { [ XF86KbdBrightnessUp ] };
};

hidden partial alphanumeric_keys
xkb_symbols "editing" {
    key <PRSC> {
    type= "PC_ALT_LEVEL2",
    symbols[Group1]= [ Print, Sys_Req ]
    };
    key <SCLK> {    [  Scroll_Lock      ]   };
    key <PAUS> {
    type= "PC_CONTROL_LEVEL2",
    symbols[Group1]= [ Pause, Break ]
    };
    key  <INS> {    [  Insert       ]   };
    key <HOME> {    [  Home         ]   };
    key <PGUP> {    [  Prior        ]   };
    key <DELE> {    [  Delete       ]   };
    key  <END> {    [  End          ]   };
    key <PGDN> {    [  Next         ]   };

    key   <UP> {    [  Up           ]   };
    key <LEFT> {    [  Left         ]   };
    key <DOWN> {    [  Down         ]   };
    key <RGHT> {    [  Right        ]   };
};' >/usr/share/x11/xkb/symbols/pc

为了以防万一,如果您需要手动添加,这里是 /usr/share/X11/xkb/symbols/altwin 的相关部分:

// Ctrl is mapped to the Alt, Alt to the Super, and Win to the Ctrl keys.
partial modifier_keys
xkb_symbols "ctrl_alt_win" {
    key <LALT> { [ Control_L, Control_L  ] };
    key <RALT> { type[Group1] = "TWO_LEVEL",
                 symbols[Group1] = [ Control_R, Control_R ] };
    key <LWIN> { [ Alt_L, Meta_L ] };
    key <RWIN> { [ Alt_R, Meta_R ] };
    key <LCTL> { [ Super_L ] };
    key <RCTL> { [ Super_R ] };
    modifier_map Control { <RALT>, <LALT> };
    modifier_map Mod1 { <LWIN>, <RWIN> };
    modifier_map Mod4 { <LCTL>, <RCTL> };
};

修改/etc/defaults/keyboard:

echo '# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:shift_nocancel,ctrl:alt,alt:win,win:ctrl"

BACKSPACE="guess"' >/etc/default/keyboard

最后,这是我的 GNOME 和 Marco 键绑定 dconf 转储:

侏儒:

[org/gnome/desktop/wm/keybindings]
activate-window-menu=['disabled']
begin-move=['disabled']
close=['<Control>q']
maximize=['<Alt><Super>m']
minimize=['<Control>m']
move-to-corner-ne=['disabled']
move-to-corner-nw=['disabled']
move-to-corner-se=['disabled']
move-to-corner-sw=['disabled']
move-to-side-e=['disabled']
move-to-side-n=['disabled']
move-to-side-s=['disabled']
move-to-side-w=['disabled']
move-to-workspace-1=['<Shift><Super>Home']
move-to-workspace-down=['<Shift><Super>Next']
move-to-workspace-up=['<Shift><Super>Prior']
show-desktop=['<Control>F3']
switch-to-workspace-1=['<Super>Home']
switch-to-workspace-down=['<Super>Next']
switch-to-workspace-up=['<Super>Prior']
switch-windows=['disabled']
switch-windows-backward=['disabled']
toggle-fullscreen=['<Control><Super>f']
toggle-maximized=['<Shift><Control>m']
toggle-shaded=['<Alt><Super>s']
unmaximize=['<Control><Alt>m']

马可:

[org/mate/marco/global-keybindings]
cycle-group='<Primary>grave'
cycle-panels='disabled'
cycle-windows='<Alt>grave'
run-command-screenshot='<Primary><Shift>numbersign'
run-command-window-screenshot='<Primary><Shift>dollar'
show-desktop='<Primary>F3'
switch-group='<Alt>Tab'
switch-to-workspace-1='<Primary><Mod4>1'
switch-to-workspace-2='<Primary><Mod4>3'
switch-to-workspace-3='<Primary><Mod4>2'
switch-to-workspace-4='<Primary><Mod4>4'
switch-to-workspace-down='<Mod4>Down'
switch-to-workspace-left='<Mod4>Left'
switch-to-workspace-prev='<Shift><Mod4>Tab'
switch-to-workspace-right='<Mod4>Right'
switch-to-workspace-up='<Mod4>Up'
switch-windows='<Primary>Tab'

[org/mate/marco/window-keybindings]
activate-window-menu='disabled'
begin-move='<Primary><Shift><Mod4>m'
begin-resize='<Primary><Shift><Mod4>r'
close='<Primary>q'
maximize='<Alt><Mod4>m'
maximize-horizontally='<Alt><Mod4>h'
maximize-vertically='<Alt><Mod4>v'
minimize='<Primary>m'
move-to-corner-ne='<Alt><Mod4>2'
move-to-corner-nw='<Alt><Mod4>1'
move-to-corner-se='<Alt><Mod4>4'
move-to-corner-sw='<Alt><Mod4>3'
move-to-side-e='<Alt><Mod4>Left'
move-to-side-n='<Alt><Mod4>Up'
move-to-side-s='<Alt><Mod4>Down'
move-to-side-w='<Alt><Mod4>Right'
move-to-workspace-1='<Primary><Alt><Mod4>1'
move-to-workspace-2='<Primary><Alt><Mod4>2'
move-to-workspace-3='<Primary><Alt><Mod4>3'
move-to-workspace-4='<Primary><Alt><Mod4>4'
move-to-workspace-down='<Primary><Mod4>Down'
move-to-workspace-left='<Primary><Mod4>Left'
move-to-workspace-right='<Primary><Mod4>Right'
move-to-workspace-up='<Primary><Mod4>Up'
tile-to-corner-ne='<Shift><Alt>at'
tile-to-corner-nw='<Shift><Alt>exclam'
tile-to-corner-se='<Shift><Alt>dollar'
tile-to-corner-sw='<Shift><Alt>numbersign'
tile-to-side-e='<Shift><Alt>Right'
tile-to-side-w='<Shift><Alt>Left'
toggle-fullscreen='<Primary><Mod4>f'
toggle-maximized='<Primary><Shift>m'
toggle-shaded='<Alt><Mod4>s'
unmaximize='<Alt><Mod4>r'

相关内容