39

Now that Unity is gone, the usual way of setting a Compose Key (via Keyboard Preferences > Layout) no longer works (because in Ubuntu 18.04, Devices > Keyboard has no Layout tab).

How do we set a Compose Key in Ubuntu 18.04 Bionic Beaver?

40

You may use (GNOME) Tweaks to set the option.

First install Tweaks by running

sudo apt install gnome-tweaks

(or sudo apt install gnome-tweak-tool).

Alternatively, for those who prefer the GUI:

  1. launch the Ubuntu Software application.

  2. search for "gnome tweaks".

  3. install.

Then launch Tweaks and go to "Keyboard & Mouse" section. The "Compose Key" options is disabled by default. Click on the "Disabled" button.

enter image description here

Then a window will pop up. Toggle the switch at the top on and then you'll be select the compose key

enter image description here

7
  • 2
    I don't have Scroll Lock, so I tried PrtScn, RightAlt, and none of them worked, what I'm missing?
    – Michael
    Sep 3 '18 at 11:02
  • 1
    Same here, I set it to Right Alt and it doesn't work.
    – zwolin
    Sep 26 '18 at 15:04
  • @zwolin Did you check out the question posted by Michael?
    – pomsky
    Sep 26 '18 at 15:11
  • 1
    @pomsky thank you, now I did. But it didn't help my case. I solved it just now by setting in GNOME Tweaks: Keyboard & Mouse -> Additional Layout Options ->Key to choose the 3rd level -> Right Alt. And now my Polish diacritic characters work as expected
    – zwolin
    Sep 26 '18 at 15:46
  • Maybe I should ask this as a separate question but is it possible to somehow set multiple compose keys (left and right alt)? It does not seem possible using the Tweaks menu.
    – Kvothe
    Nov 5 '18 at 14:36
12

To expand upon what @pomsky detailed in their answer, the official documentation covers the two solutions available.

One is through installing Gnome Tweak Tool via the terminal like so: sudo apt install gnome-tweak-tool

And the other is typing the Unicode character's code point. To do this, press Ctrl+Shift+U, release all keys (you'll see an underlined u), type the code point desired, and then press Space or Enter to complete.

For example, a common one I use is referred to as “Smart Quotes” which are U+201C & U+201D respectively. So you would type 201C or 201D after releasing the initial keys, and complete the process with Space or Enter.

4

The dconf setting that worked for my GNOME 3.28.2 is

/org/gnome/desktop/input-sources/xkb-options

To set the Scroll Lock as the compose key, the value should be

['compose:sclk']

See the gnome-tweaks source code for other potential values.

That means you can run a command like this:

dconf write /org/gnome/desktop/input-sources/xkb-options "['compose:sclk']"
2
  • 1
    In case you would like to define multiple compose keys, simply extend the array: ['compose:prsc', 'compose:rwin']. Another way to show the list of possible keys: grep "compose:" /usr/share/X11/xkb/rules/base.lst
    – ph0t0nix
    Jul 9 '19 at 9:27
  • 1
    Eg dconf write /org/gnome/desktop/input-sources/xkb-options "['compose:sclk']" Aug 30 '19 at 3:54
4

Issue man xkeyboard-config and look for the compose options (shortcut: enter /compose:). You will find

compose:ralt          Right Alt                  
compose:lwin          Left Win                   
compose:lwin-altgr    3rd level of Left Win      
compose:rwin          Right Win                  
compose:rwin-altgr    3rd level of Right Win     
compose:menu          Menu                       
compose:menu-altgr    3rd level of Menu          
compose:lctrl         Left Ctrl                  
compose:lctrl-altgr   3rd level of Left Ctrl     
compose:rctrl         Right Ctrl                 
compose:rctrl-altgr   3rd level of Right Ctrl    
compose:caps          Caps Lock                  
compose:caps-altgr    3rd level of Caps Lock     
compose:102           <Less/Greater>             
compose:102-altgr     3rd level of <Less/Greater>
compose:paus          Pause                      
compose:prsc          PrtSc                      
compose:sclk          Scroll Lock                

Let us say you want to pick Pause as the compose key. Just issue

setxkbmap -option compose:paus

To make it reboot-persistent, open /etc/default/keyboard with your favorite editor.

sudo nano /etc/default/keyboard

and to the line XKBOPTIONS add compose:paus. If you had other options already, separate them with commas. For example:

XKBOPTIONS="terminate:ctrl_alt_bksp,compose:paus"

Multiple compose keys can be used simultaneously.

3
  • 1
    Always nice to have a pure CLI alternative Thanks!
    – Tim
    Oct 17 '20 at 12:43
  • 1
    @Tim You are welcome! This has an advantage of not requiring Gnome or Ubuntu or anything of the sort, only X11.
    – Quasímodo
    Oct 17 '20 at 15:11
  • setxkbmap -option compose:paus work for me but changing XKBOPTIONS="terminate:ctrl_alt_bks,compose:paus" In /etc/default/keyboard dont work for me :/ I don't understand.
    – 1000i100
    Jul 8 at 20:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.