如何在Ubuntu 16.04的Dvorak中获得带有点的A?


8

我想在Ubuntu 16.04的Macbook Air 2013-mid键盘中以点(Ä/ ä)作为A 级键盘绑定键入A ,输出为setxkbmap -query

rules:      evdev
model:      pc105
layout:     us,us
variant:    dvorak,
options:    ctrl:nocaps

默认情况下,AltGr键盘上没有两个Alt。此命令使您右移组合键(AltGr),但保留您自己的自定义键盘配置,例如以Capslock为CTRL by caps:ctrl_modifier,请参见此处

gsettings set org.gnome.desktop.input-sources xkb-options \
    "$(gsettings get org.gnome.desktop.input-sources xkb-options \ 
    | sed "s/]/, 'compose:ralt']/")"

xmodmap如果将要更改此解决方案,因为它将被折旧,那么拥有独立的解决方案将是非常不错的。

两级键绑定方法

我们只能对带有死键的Dvorak International进行两级键绑定方法。

  • SeverusTux的答案有两个级别命令AltGr- Shift- Q+ A,仅在工作us-drovak, international with deadkeys
  • SeverusTux。Ctrl+ Shift+ u+ e4+ Enter可以给你ä。您如何将其映射到一级键绑定Alt- a

当您看到GUI在其他地方进行更改时,我会这样做。我真的很想知道在哪里

masi@masi:~$ cat /usr/share/X11/locale/en_US.UTF-8/Compose > /home/masi/Desktop/test1
% I make here a change in the GUI as proposed by Severus: compose key = right Alt
masi@masi:~$ cat /usr/share/X11/locale/en_US.UTF-8/Compose > /home/masi/Desktop/test2
masi@masi:~$ diff /home/masi/Desktop/test1 /home/masi/Desktop/test2
[ no output ]

这表明xserver不会快速更新。您必须将键盘更改为其他键盘,然后再次返回以进行更改。

一键式绑定方法

我想一个级别的命令AltGr- AäAltGr- Shift- AÄ英语(US-德沃夏克)。我xev -e keyboardAltGr

[ignore the beginning; press AltGr]
KeyPress event, serial 28, synthetic NO, window 0x4400001, 
root 0xd6, subw 0x0, time 13661220, (186,522), root:(186,574), 
state 0x0, keycode 108 (keysym 0xffea, Alt_R), same_screen YES, 
XLookupString gives 0 bytes: 
XmbLookupString gives 0 bytes: 
XFilterEvent returns: False 

KeyRelease event, serial 28, synthetic NO, window 0x4400001, 
root 0xd6, subw 0x0, time 13661284, (186,522), root:(186,574), 
state 0x8, keycode 108 (keysym 0xffea, Alt_R), same_screen YES, 
XLookupString gives 0 bytes: 
XFilterEvent returns: False

您可以通过以下方式获得所有可能的开关,more /usr/share/X11/xkb/rules/xorg.lst | grep lv3但我们仅对lv3:ralt_switch

  lv3:switch           Right Ctrl
  lv3:menu_switch      Menu
  lv3:win_switch       Any Win key
  lv3:lwin_switch      Left Win
  lv3:rwin_switch      Right Win
  lv3:alt_switch       Any Alt key
  lv3:lalt_switch      Left Alt
  lv3:ralt_switch      Right Alt
  lv3:ralt_switch_multikey Right Alt, Shift+Right Alt key is Compose
  lv3:ralt_alt         Right Alt key never chooses 3rd level
  lv3:enter_switch     Enter on keypad
  lv3:caps_switch      Caps Lock
  lv3:bksl_switch      Backslash
  lv3:lsgt_switch      <Less/Greater>
  lv3:caps_switch_latch Caps Lock chooses 3rd level, acts as onetime lock when pressed together with another 3rd-level-chooser
  lv3:bksl_switch_latch Backslash chooses 3rd level, acts as onetime lock when pressed together with another 3rd-level-chooser
  lv3:lsgt_switch_latch <Less/Greater> chooses 3rd level, acts as onetime lock when pressed together with another 3rd-level-chooser

我的键盘布局已经过测试,但是主要的英语(美国-dvorak)

在此处输入图片说明

最终解决方案[Sneetsher]

我将英文(dvorak)的点设置为AltGr- a。合并中的变化/usr/share/X11/xkb/symbols/us; 现在是德语-德沃夏克语,因为它也适用于斯堪的纳维亚语言(从此处开始

// based on a keyboard map from an 'xkb/symbols/dk' file
// Added A with dots and O with dots for AltGr-A and AltGr-O, respectively. Sneether and Masi, 17-June-2016.

partial alphanumeric_keys
xkb_symbols "dvorak" {

    name[Group1]= "English (Dvorak)";

    key <TLDE> { [       grave, asciitilde, dead_grave, dead_tilde      ] };

    key <AE01> { [          1,  exclam          ]       };
    key <AE02> { [          2,  at              ]       };
    key <AE03> { [          3,  numbersign      ]       };
    key <AE04> { [          4,  dollar          ]       };
    key <AE05> { [          5,  percent         ]       };
    key <AE06> { [          6,  asciicircum, dead_circumflex, dead_circumflex ] };
    key <AE07> { [          7,  ampersand       ]       };
    key <AE08> { [          8,  asterisk        ]       };
    key <AE09> { [          9,  parenleft,  dead_grave] };
    key <AE10> { [          0,  parenright      ]       };
    key <AE11> { [ bracketleft, braceleft       ]       };
    key <AE12> { [ bracketright, braceright,  dead_tilde] };

    key <AD01> { [  apostrophe, quotedbl, dead_acute, dead_diaeresis    ] };
    key <AD02> { [      comma,  less,   dead_cedilla, dead_caron        ] };
    key <AD03> { [      period, greater, dead_abovedot, periodcentered  ] };
    key <AD04> { [          p,  P               ]       };
    key <AD05> { [          y,  Y               ]       };
    key <AD06> { [          f,  F               ]       };
    key <AD07> { [          g,  G               ]       };
    key <AD08> { [          c,  C               ]       };
    key <AD09> { [          r,  R               ]       };
    key <AD10> { [          l,  L               ]       };
    key <AD11> { [      slash,  question        ]       };
    key <AD12> { [      equal,  plus            ]       };

    key <AC01> {[ a,          A,    adiaeresis,       Adiaeresis ]      };
    key <AC02> {[ o,          O,    odiaeresis,       Odiaeresis ]      };
    key <AC03> { [ e, E, ediaeresis, Ediaeresis ] };
    key <AC04> { [ u, U, udiaeresis, Udiaeresis ] };
    key <AC05> { [          i,  I               ]       };
    key <AC06> { [          d,  D               ]       };
    key <AC07> { [          h,  H               ]       };
    key <AC08> { [          t,  T               ]       };
    key <AC09> { [          n,  N               ]       };
    key <AC10> { [ s, S, ssharp ] };
    key <AC11> { [      minus,  underscore      ]       };

    key <AB01> { [   semicolon, colon, dead_ogonek, dead_doubleacute ] };
    key <AB02> { [          q,  Q               ]       };
    key <AB03> { [          j,  J               ]       };
    key <AB04> { [          k,  K               ]       };
    key <AB05> { [          x,  X               ]       };
    key <AB06> { [          b,  B               ]       };
    key <AB07> { [          m,  M               ]       };
    key <AB08> { [          w,  W               ]       };
    key <AB09> { [          v,  V               ]       };
    key <AB10> { [          z,  Z               ]       };

    key <BKSL> { [  backslash,  bar             ]       };

    include "level3(ralt_switch)"
};

或使用脚本,但仍然有问题

# restore your current keyboard settings 
sudo apt-get install --reinstall xkb-data
gsettings set org.gnome.desktop.input-sources xkb-options "['compose:ralt', 'caps:ctrl_modifier']"

sudo sed -i.bak 's/[[ \t]*a,[ \t]*A[ \t]*]/[ a,          A,    adiaeresis,       Adiaeresis ]/g;' /usr/share/X11/xkb/symbols/us; 
sudo sed -i.bak 's/[[ \t]*o,[ \t]*O[ \t]*]/[ o,          O,    odiaeresis,       Odiaeresis ]/g;' /usr/share/X11/xkb/symbols/us; 
# German-Dvorak feels better
#sudo sed -i.bak 's/[[ \t]*e,[ \t]*E[ \t]*]/[ e,          E,    ediaeresis,       Ediaeresis ]/g;' /usr/share/X11/xkb/symbols/us; 
#sudo sed -i.bak 's/[[ \t]*u,[ \t]*U[ \t]*]/[ u,          U,    udiaeresis,       Udiaeresis ]/g;' /usr/share/X11/xkb/symbols/us; 
#sudo sed -i.bak 's/[[ \t]*s,[ \t]*S[ \t]*]/[ s,          S,    ssharp ]/g;' /usr/share/X11/xkb/symbols/us; 

# add     include "level3(ralt_switch)" to the end of the environment
# https://unix.stackexchange.com/a/290407/16920
# https://unix.stackexchange.com/q/290405/16920
pos=( $( sed -n -f - /usr/share/X11/xkb/symbols/us <<END_SED
    /xkb_symbols "dvorak" {/,/^};/{
            /xkb_symbols "dvorak" {/=
            /^};/=
    }
END_SED
) )
sudo sed -i.bak "${pos[1]}i\    include \"level3(ralt_switch)\"" /usr/share/X11/xkb/symbols/us

sudo dpkg-reconfigure xkb-data
# Change your keyboard. Change Back. Should work. But some bug. I cannot get the script works stably. 

虫子

  1. 将键盘重新加载到xserver的TODO问题https://unix.stackexchange.com/q/290449/16920手动更改并不总是有效。
  2. 并发症:Xserver不能快速加载那些密钥,即使在重启/注销后的所有情况下也不能加载。

系统:Ubuntu 16.04
Linux内核: 4.4-4.6
键盘模型:pc105
用于两级键绑定方法的键盘布局:具有死
键的US-dvorak国际键盘用于一级键绑定方法的键盘布局:英语(Dvorak) = US-dvorak,也可以英语(经典德沃夏克)


1
按,ctrl+shift+u然后键入e4,然后按Enter。如果可行,那么您可以尝试进一步获得一个简单的密钥。
西弗勒斯·图克斯

我已经写了我刚才说的答案,如果您有任何疑问,请留下评论
Severus Tux

Answers:


8
  • 要输入ä,unicode是U00E4

  • 要键入Ä,unicode是U00C4

如果需要其他字符的unicode,可以从 gucharmap

要手动输入,请按ctrl+ shift+ u,然后按00e4并单击Enter,应输入ä

但是有一种使用Compose Keys更好的方法。

如果要 Right alt 使用命令行将的键设置为撰写键:只需执行以下命令

gsettings set org.gnome.desktop.input-sources xkb-options "['compose:ralt']"

如果要使用GUI进行设置:

通过转到系统设置->键盘->键入->右Alt来启用撰写键。(如果需要,可以选择其他键)

在此处输入图片说明

就这样 !!

现在转到您喜欢的文本编辑器并执行以下操作:

按下并释放Right Alt"然后按a。现在您应该看到ä

同样可以做到Ä,新闻发布Right Alt之后",随后A

注意:您可能需要按Shift+ '才能获取"

小费:

如果您希望看到所有类似的快捷方式,请查看此文件:/usr/share/X11/locale/en_US.UTF-8/Compose


@Masi该文件只是所有Compose键组合的列表。只是额外的信息。
UniversallyUniqueID

@Masi无需编辑该文件或用替换任何内容sed,正如@BharadwajRaju所说的那样,这是额外的信息,如果您需要其他特殊符号的快捷键,则可以简单地查看它。那是所有此类快捷方式的巨大列表
Severus Tux

1
@Masi,所以您只想使用命令行而不是使用GUI来设置撰写键?
西弗勒斯·图克斯

@Masi答案已更新:-)您不需要任何脚本。只需一个简单的命令即可解决问题。希望这就是您想要的
Severus Tux

您用什么制作了很棒的gif?很好
Bhikkhu Subhuti

7

英文(德沃夏克(Dvorak),带死键的国际键)- dvorak-intl 效果很好!

我可以Ä使用ShiftAltGrq默认设置输入。查看文件/usr/share/X11/xkb/symbols/us,其中q密钥声明为

key <AB02> { [ q, Q, adiaeresis, Adiaeresis ] };

level3(ralt_switch)在底部使用Right Alt/ AltGr作为第三级移位,以便

  • 第一栏qq
  • 第二列QShiftq
  • 第三列äAltGrq
  • 第四栏ÄShiftAltGrq

可视化

X11 XKB布局级别

  • dvorak-intl 仅定义了4个级别,我将XKB支持的所有8个级别都绘制出来,以便您可以大致了解。
  • Shift是标准的level2移位,AltGr是大多数需要level3&4的布局的默认level3移位。只有很少的布局定义了level5、6、7、8,因此level5的移位键RCtrl仅用于说明。
  • 定义<AB02>密钥的所有这4行都是等效的。

设置äÄ在第3和第4级a英语(德沃夏克)键- dvorak布局

加上öÖo键。(它没有出现在屏幕截图中,因为它是在屏幕截图之后添加的)

与相同dvorak-intl,我们可以对进行相同的设置dvorak

  1. 清除以前的修改

    sudo apt-get install --reinstall xkb-data
    gsettings set org.gnome.desktop.input-sources xkb-options "[]"
    
  2. 检查站

    • 尝试使用英语(德沃夏克(Dvorak),带死键的国际电话)- dvorak-intl

      AltGrq打印ä。如果它不起作用,则此设置将是同样的问题。有一些阻止Right Alt在level3转换中工作的功能。

      英文(德沃夏克(Dvorak),带死键的国际电话)

    • 验证当前的地图 dvorak

      英文(德沃夏克语)

    • 验证Right Alt映射,应该是 Alt_R

      $ xev -e keyboard
      [ignore start things; press AltGr]
      
      KeyPress event, serial 28, synthetic NO, window 0x3400001,
          root 0x281, subw 0x0, time 1855861, (769,284), root:(834,336),
          state 0x10, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
          XLookupString gives 0 bytes: 
          XmbLookupString gives 0 bytes: 
          XFilterEvent returns: False
      
      KeyRelease event, serial 28, synthetic NO, window 0x3400001,
          root 0x281, subw 0x0, time 1855965, (769,284), root:(834,336),
          state 0x18, keycode 108 (keysym 0xffea, Alt_R), same_screen YES,
          XLookupString gives 0 bytes: 
          XFilterEvent returns: False
      
  3. 修改a地图

    $ sudo vim /usr/share/X11/xkb/symbols/us +224
    
    key <AD11> { [      slash,  question        ]       };
    key <AD12> { [      equal,  plus            ]       };
    
    key <AC01> { [          a,  A, adiaeresis, Adiaeresis ]       };
    key <AC02> { [          o,  O, odiaeresis, Odiaeresis ]       };
    key <AC03> { [          e,  E               ]       };
    
  4. 将Right Alt设置为level3 shift

    $ sudo vim /usr/share/X11/xkb/symbols/us +248
    
        key <AB09> { [          v,  V               ]       };
        key <AB10> { [          z,  Z               ]       };
    
        key <BKSL> { [  backslash,  bar             ]       };
    
        include "level3(ralt_switch)"
    };
    
    // Dvorak international with dead keys
    

    有许多可以用作ISO_Level3_Shift的键。检查可用选项

    $ more /usr/share/X11/xkb/rules/xorg.lst | grep lv3:
      lv3:switch           Right Ctrl
      lv3:menu_switch      Menu
      lv3:win_switch       Any Win key
      lv3:lwin_switch      Left Win
      lv3:rwin_switch      Right Win
      lv3:alt_switch       Any Alt key
      lv3:lalt_switch      Left Alt
      lv3:ralt_switch      Right Alt
      lv3:ralt_switch_multikey Right Alt, Shift+Right Alt key is Compose
      lv3:ralt_alt         Right Alt key never chooses 3rd level
      lv3:enter_switch     Enter on keypad
      lv3:caps_switch      Caps Lock
      lv3:bksl_switch      Backslash
      lv3:lsgt_switch      &lt;Less/Greater&gt;
      lv3:caps_switch_latch Caps Lock chooses 3rd level, acts as onetime lock when pressed together with another 3rd-level-chooser
      lv3:bksl_switch_latch Backslash chooses 3rd level, acts as onetime lock when pressed together with another 3rd-level-chooser
      lv3:lsgt_switch_latch &lt;Less/Greater&gt; chooses 3rd level, acts as onetime lock when pressed together with another 3rd-level-chooser
    

    例如,如果您想将Caps Lock用作level3移位,请输入include "level3(caps_switch)"而不是include "level3(ralt_switch)"

  5. 强制重新布局

    sudo dpkg-reconfigure xkb-data
    

    更改为其他布局,然后返回。

  6. 检查点

    • 验证当前的地图 dvorak

      英文(德沃夏克语)

    • 验证右Alt映射。它应该是ISO_Level3_Shift

      $ xev -e keyboard
      
      KeyPress event, serial 35, synthetic NO, window 0x3600001,
          root 0x281, subw 0x0, time 4755266, (154,154), root:(219,206),
          state 0x0, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
          XKeysymToKeycode returns keycode: 92
          XLookupString gives 0 bytes: 
          XmbLookupString gives 0 bytes: 
          XFilterEvent returns: False
      
      KeyRelease event, serial 35, synthetic NO, window 0x3600001,
          root 0x281, subw 0x0, time 4755435, (154,154), root:(219,206),
          state 0x80, keycode 108 (keysym 0xfe03, ISO_Level3_Shift), same_screen YES,
          XKeysymToKeycode returns keycode: 92
          XLookupString gives 0 bytes: 
          XFilterEvent returns: False
      

现在,它应该可以工作了!


一线指令

cd /; \
echo -e "--- /usr/share/X11/xkb/symbols/us\t2016-01-22 09:38:25.000000000 +0100\n+++ /usr/share/X11/xkb/symbols/us\t2016-06-17 15:43:07.656076074 +0100\n@@ -221,8 +221,8 @@\n     key <AD11> { [\tslash,\tquestion\t]\t};\n     key <AD12> { [\tequal,\tplus\t\t]\t};\n \n-    key <AC01> { [\t    a,\tA \t\t]\t};\n-    key <AC02> { [\t    o,\tO\t\t]\t};\n+    key <AC01> { [\t    a,\tA, adiaeresis, Adiaeresis ]\t};\n+    key <AC02> { [\t    o,\tO, odiaeresis, Odiaeresis ]\t};\n     key <AC03> { [\t    e,\tE\t\t]\t};\n     key <AC04> { [\t    u,\tU\t\t]\t};\n     key <AC05> { [\t    i,\tI\t\t]\t};\n@@ -245,6 +245,8 @@\n     key <AB10> { [\t    z,\tZ\t\t]\t};\n \n     key <BKSL> { [  backslash,  bar             ]       };\n+\n+    include \"level3(ralt_switch)\"\n };\n \n // Dvorak international with dead keys\n" \
| sudo patch -p1; \
sudo dpkg-reconfigure xkb-data; \
cl=$(gsettings get org.gnome.desktop.input-sources current); \
gsettings set org.gnome.desktop.input-sources current 0; \
gsettings set org.gnome.desktop.input-sources current 1; \
gsettings set org.gnome.desktop.input-sources current "$cl"

2
评论不作进一步讨论;此对话已转移至聊天
米奇

1
我发现手动更换键盘并不总是有效。直到您注销,更改才有效。我想到了一个解决方案在这里unix.stackexchange.com/questions/290449/...
莱奥列奥波尔德·赫兹준 영

我发现了一个我不理解的错误。此sudo sed -i "${pos[1]}i\ include 'level3(ralt_switch)'" /usr/share/X11/xkb/symbols/us行使键盘在启动时无法使用。您不能在键盘上键入任何键。它只是在第249行的末尾Dvorak环境中添加了level3。第249行的位置正确吗?
莱奥波德·赫兹(LéoLéopoldHertz)2016年

@Masi,是的,但是应该是248而不是249!并确保您已经${pos[1]} 定义过。
user.dz

我在unix.stackexchange.com/q/346073/16920处针对这种情况打开了一个新线程,因为我确实确实在OS中更稳定地需要此类功能。
莱奥波尔德·赫兹(LéoLéopoldHertz),2017年
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.