Ubuntu – How to Get A with Dots in Dvorak of Ubuntu 16.04

dead keysdvorak

I want to type A with dots (Ä / ä) as one-level keybinding in Ubuntu 16.04's keyboard of Macbook Air 2013-mid, output of setxkbmap -query

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

By default, there is no AltGr in the keyboard, just two Alts. This command makes your right alt the compose key (AltGr) but maintains your own custom keyboard configurations etc having Capslock as CTRL by caps:ctrl_modifier, see here

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

It would be really great to have xmodmap independent solution if this is going to be changed because it is going to be depreciated.

Two-level keybinding approach

We can only do two-level keybinding approach with Dvorak International with deadkeys.

  • SeverusTux's answer is two-level command as AltGrShiftQ + A, which works only in us-drovak, international with deadkeys.
  • SeverusTux. Ctrl+Shift+u +e4 + Enter works and gives you ä. How can you map this to a one-level keybinding Alta?

I do where you see that the GUI make the change elsewhere. I really want to know where

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 ]

This shows that the xserver does not update fast. You have to change your keyboard to something else and back again, for the change.

One-level Keybinding Approach

I want one-level command as AltGrA for ä and AltGrShiftA for Ä in English(US-dvorak).
I do xev -e keyboard and press AltGr

[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

You can get all possible switches by more /usr/share/X11/xkb/rules/xorg.lst | grep lv3 but we are only interested in 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

My keyboard layouts tested but main English(US-dvorak)

enter image description here

Final solution [Sneetsher]

I set A with dots in English(dvorak) by AltGra. Merge the changes in/usr/share/X11/xkb/symbols/us; now German-Dvorak because it works very well for Scandinavian languages too (from here)

// 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)"
};

Or use the script which is however still buggy

# 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. 

Bugs

  1. TODO problem with reloading the keyboard back to xserver https://unix.stackexchange.com/q/290449/16920 The manual change does not work always.
  2. Complications: Xserver does not load those keys fast and not even in all cases after restart/logout.

Systems: Ubuntu 16.04
Linux kernel: 4.4 – 4.6
Keyboard model: pc105
Keyboard layout for two-level keybinding approach: US-dvorak international with deadkeys
Keyboard layout for one-level keybinding approach: English (Dvorak) = US-dvorak, but also English (Classic Dvorak)

Best Answer

  • To type ä , unicode is U00E4

  • To type Ä , unicode is U00C4

If you want the unicodes of other characters, you can get them from gucharmap

To enter it manually, press ctrl+shift+u and followed by 00e4 and hit Enter , this should type ä

But there is a better way to do this using Compose Keys.

If you want to set your Right alt as the compose key using command line: just execute this :

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

If you want to set it suing GUI :

Enable compose key by going to System Settings --> Keyboard --> Typing --> Right Alt. (you can chose a different key if you wish)

enter image description here

Thats all !!

Now go to your favorite text editor and do this :

Press and release Right Alt followed by " followed by a. now you should see ä .

The same can be done for Ä , Press and release Right Alt followed by " followed by A

NOTE : you might need to press Shift+' to get "

TIP:

If you wish to see all similar shortcuts view this file : /usr/share/X11/locale/en_US.UTF-8/Compose

Related Question