User:John3-16/Compose key: Difference between revisions

From Alpine Linux
No edit summary
No edit summary
Line 1: Line 1:
{{TOC right}}
{{TOC right}}


A '''compose key''' can be assigned to quickly produce certain characters from a keyboard, such as a letter with an accent such as '''é''', or with a diacritic such as '''ç''', or certain symbols and emojis such as '''≥''', '''☺''', etc. They could be composed within various applications, including various text editors, shells or certain other packages.  For example, if one were to choose the <AltGr> key as the '''compose key''' in one's installation, depending on the configuration method chosen, one may obtain the character "é" by pressing the following three characters one after another:
A '''compose key''' may be assigned to quickly produce certain characters from a keyboard.  For example:
* a letter with an accent such as '''é''' ; or  
* a letter with a diacritic such as '''ç'''or  
* certain symbols and emojis such as '''≥''', '''☺''', etc.
They could be composed within various applications, including various text editors, shells or certain other packages.  For example, if one were to choose the <AltGr> key as the '''compose key''' in one's installation, depending on the configuration method chosen, one may obtain the character "é" by pressing the following three characters one after another:


  <AltGr> + <'> + <e> = é
  <AltGr> + <'> + <e> = é
Line 38: Line 42:


{{Todo|<nowiki>
{{Todo|<nowiki>


Elaborate on alternative methods, including 'Xcompose'; document assigning the compose key for all users.
Elaborate on alternative methods, including 'Xcompose'; document assigning the compose key for all users.
Contributors welcome.}}</nowiki>}}
Contributors welcome.}}</nowiki>}}


Line 59: Line 61:


=== In desktop environments ===
=== In desktop environments ===
 
If the desktop environment is installed via <code>pkg|setup-desktop</code>, one could seek to assign the compose key through could one of the desktop's "Settings" modules and then, specifically, those relating to "Keyboard" or similar:
If the desktop environment is installed via `setup-desktop`, one could seek to assign the compose key through could one of the desktop's 'Settings' modules and then, specifically, those relating to 'Keyboard' or similar:


==== [https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/customizing_the_gnome_desktop_environment/special-characters-in-gnome_customizing-the-gnome-desktop-environment Gnome] ====
==== [https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/9/html/customizing_the_gnome_desktop_environment/special-characters-in-gnome_customizing-the-gnome-desktop-environment Gnome] ====
  Activities (on toolbar) \ type the word "Settings" \ Settings icon \ Keyboard \ enable "Compose Key" \ select the Compose Key
  Activities (on toolbar) \ type the word "Settings" \ Settings icon \ Keyboard \ enable "Compose Key" \ select the Compose Key


==== [https://xfce.org XFCE] ====
==== [https://xfce.org XFCE] ====
  Applications \ Settings \ Settings Editor \  Channel "keyboard-layout" \ XkbOptions \ Compose \ type `compose:ralt` or otherwise for your preferred compose key
  Applications \ Settings \ Settings Editor \  Channel "keyboard-layout" \ XkbOptions \ Compose \ type `compose:ralt` or otherwise for your preferred compose key


==== [https://wiki.mate-desktop.org/ Mate] ====
==== [https://wiki.mate-desktop.org/ Mate] ====
  System \ Control Centre \ Keyboard \ Layout \ Options \ Position of Compose Key clcik on triangle \ Select your compose key
  System \ Control Centre \ Keyboard \ Layout \ Options \ Position of Compose Key clcik on triangle \ Select your compose key


==== [https://github.com/swaywm/sway/wiki Sway] ====
==== [https://github.com/swaywm/sway/wiki Sway] ====
Check your input settings first:
Check your input settings first:


{{Cmd| $ swaymsg -t get_inputs}}
{{Cmd| $ swaymsg -t get_inputs}}


If your preferred compose key is not stated, then open your configuration file (`~/.config/sway/config`) with your preferred text editor, and in order to specify that the <AltGr> key/'right alt' key is your compose key, consider entering the following `xkb_options` line inside the `input "type:keyboard"` stanza, as follows (without the `[...]`):
If your preferred compose key is not stated, then open your configuration file (<code>~/.config/sway/config</code>) with your preferred text editor, and in order to specify that the <AltGr> key/'right alt' key is your compose key, consider entering the following <code>xkb_options</code> line inside the <code>input "type:keyboard"</code> stanza, as follows (without the <code>[...]</code>):


  input "type:keyboard" {
  input "type:keyboard" {
Line 88: Line 85:


==== [https://github.com/lxqt/lxqt/wiki LXQt] ====
==== [https://github.com/lxqt/lxqt/wiki LXQt] ====
===== Under XOrg: =====
===== Under XOrg: =====
Consider following the [[XOrg window sessions|passage below for 'XOrg window sessions']], installing {{Pkg|setxkbmap}} first, and then applying the autostart instruction by going to:
Consider following the [[XOrg window sessions|passage below for 'XOrg window sessions']], installing {{Pkg|setxkbmap}} first, and then applying the autostart instruction by going to:
  Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add
  Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add


Add a line with your chosen compose key setting, such as:
Add a line with your chosen compose key setting, such as:
  /usr/bin/setxkbmap -option compose:ralt &
  /usr/bin/setxkbmap -option compose:ralt &


===== Under Wayland: =====
===== Under Wayland: =====
Consider applying the guide below, [[Under Wayland|Under Wayland]]
Consider applying the guide below, [[Under Wayland|Under Wayland]]




If the [[KDE|Plasma]] desktop environment is installed:
If the [[KDE|Plasma]] desktop environment is installed:
===== [https://userbase.kde.org/System_Settings/Input_Devices/en#Enable_Compose_key Plasma] =====
===== [https://userbase.kde.org/System_Settings/Input_Devices/en#Enable_Compose_key Plasma] =====


Line 112: Line 102:


The desktop environment's [https://en.wikipedia.org/wiki/Man_page man pages]] may give more detailed configurations for the compose key.  The following section may also be additionally be useful e.g. where one drops into a tty environment or when switching into a different window manager/compositor than those listed above.
The desktop environment's [https://en.wikipedia.org/wiki/Man_page man pages]] may give more detailed configurations for the compose key.  The following section may also be additionally be useful e.g. where one drops into a tty environment or when switching into a different window manager/compositor than those listed above.


=== Without set desktop environments ===  
=== Without set desktop environments ===  
From the following examples, consider the model where the <AltGr> key ('ralt' key) could be assigned for the user only.  If a different key is preferred, consider substituting with the key's technical term listed above.
From the following examples, consider the model where the <AltGr> key ('ralt' key) could be assigned for the user only.  If a different key is preferred, consider substituting with the key's technical term listed above.


==== Under XOrg ====
==== Under XOrg ====
There are various methods. Consider installing {{pkg|setxkbmap}}.
There are various methods. Consider installing {{pkg|setxkbmap}}.


{{Cmd| $ doas apk add setxkbmap }}
{{Cmd| $ doas apk add setxkbmap }}


===== For XOrg window sessions: =====
===== For XOrg window sessions: =====
In your window manager's autostart file, consider entering the following:
In your window manager's autostart file, consider entering the following:


  /usr/bin/setxkbmap -option compose:ralt &  
  /usr/bin/setxkbmap -option compose:ralt &  


If there is no austostart file, consider adding that instruction in <code>~/.xinitrc</code> before the last line(s) being used to launch any window session.  
If there is no austostart file, consider adding that instruction in <code>~/.xinitrc</code> before the last line(s) being used to launch any window session.  
Line 139: Line 121:


===== For tty/windowless sessions: =====
===== For tty/windowless sessions: =====
The same '''setxkbmap''' instruction could be used at the tty.   
The same '''setxkbmap''' instruction could be used at the tty.   


Line 165: Line 146:


==== Under Wayland ====
==== Under Wayland ====
Consider [https://superuser.com/questions/1160777/make-special-characters-available-on-us-keyboard-an-wayland various approaches];    Sway's method suggested above could be considered first for that compositor.
Consider [https://superuser.com/questions/1160777/make-special-characters-available-on-us-keyboard-an-wayland various approaches];    Sway's method suggested above could be considered first for that compositor.


Line 172: Line 152:


  export XKB_DEFAULT_OPTIONS="compose:ralt"
  export XKB_DEFAULT_OPTIONS="compose:ralt"


A list of compose sequences available depend on your [https://www.x.org/releases/current/doc/libX11/i18n/compose/libX11-keys.html keyboard locale].
A list of compose sequences available depend on your [https://www.x.org/releases/current/doc/libX11/i18n/compose/libX11-keys.html keyboard locale].

Revision as of 06:08, 14 July 2025

A compose key may be assigned to quickly produce certain characters from a keyboard. For example:

  • a letter with an accent such as é ; or
  • a letter with a diacritic such as ç; or
  • certain symbols and emojis such as , , etc.

They could be composed within various applications, including various text editors, shells or certain other packages. For example, if one were to choose the <AltGr> key as the compose key in one's installation, depending on the configuration method chosen, one may obtain the character "é" by pressing the following three characters one after another:

<AltGr> + <'> + <e> = é

Other examples may include:

<AltGr> + <,> + <c> = ç
<AltGr> + <c> + <c> = č
<AltGr> + <1> + <2> = ½
<AltGr> + <=> + <E> = €
<AltGr> + <-> + <L> = £

Note also that you may need to "hold" the <Shift> key with the next character in order to produce some characters, depending on your keyboard layout. For example, on some keyboards where the colon appears over the semi-colon:

Hold<Shift>+<;> = : 

Therefore, consider the following example:

<AltGr> + <:> + <)> = ☺  

Depending on your layout, since additionally the left bracket (')) on some layouts is called by shifting the "zero" key, one may need to do as follows:

<AltGr> +  Hold<Shift>+<;> + Hold<Shift>+<0> = ☺

Note that under some environments, one may obtain an umlaut/diaeresis (¨) by employing the colon symbol (:). Alternatively, depending on your configuration, you may need to obtain the umlaut by using the double-quotes ("). For example:

<AltGr> + <"> + <a> = ä

Consider additionally that, depending on the keyboard configuration, double-quotes are sometimes composed as Hold<shift>+<'>. Therefore, depending on the keyboard configured, one might need to obtain that "ä" as follows:

<AltGr> + Hold<Shift>+<'> + <a> = ä

Consider a listing of combinations under Xorg.

Assign the compose key

Todo: Elaborate on alternative methods, including 'Xcompose'; document assigning the compose key for all users. Contributors welcome.}}


Decide what compose key you will choose. Then, you may need to refer to it in the instructions below by its technical term, which may be listed here as follows:-

  • <LWIN> or <Left Windows> key a.k.a. the 'Windows' or 'Logo' key on the left: 'lwin'
  • <RWIN> or <Right Windows> key (it exists on some keyboards and is not to be confused with the 'Windows' key on the left): 'rwin'
  • <AltGr> key a.k.a. the <Alt> key on the right: 'ralt'
  • <Alt> key on the left: 'lalt'
  • <Menu> key a.k.a. the application key, typically used to open context menus, as when right-clicking from a mouse, displaying a right-click menu and pointer, often found between the <Right Alt> and <Right Control> keys (not to be confused with the the 'Logo'/'lwin' key): 'menu'
  • <Caps Lock> key: 'caps'
  • <Pause> key: 'paus'
  • <Print Scrn> key: 'prsc'
  • <Scroll Lock> key: 'sclk'
  • <Right Control> key: 'rctrl'
  • <Left Control> key: 'lctrl'

In desktop environments

If the desktop environment is installed via pkg|setup-desktop, one could seek to assign the compose key through could one of the desktop's "Settings" modules and then, specifically, those relating to "Keyboard" or similar:

Gnome

Activities (on toolbar) \ type the word "Settings" \ Settings icon \ Keyboard \ enable "Compose Key" \ select the Compose Key

XFCE

Applications \ Settings \ Settings Editor \  Channel "keyboard-layout" \ XkbOptions \ Compose \ type `compose:ralt` or otherwise for your preferred compose key

Mate

System \ Control Centre \ Keyboard \ Layout \ Options \ Position of Compose Key clcik on triangle \ Select your compose key

Sway

Check your input settings first:

$ swaymsg -t get_inputs

If your preferred compose key is not stated, then open your configuration file (~/.config/sway/config) with your preferred text editor, and in order to specify that the <AltGr> key/'right alt' key is your compose key, consider entering the following xkb_options line inside the input "type:keyboard" stanza, as follows (without the [...]):

input "type:keyboard" {
  [...]
  xkb_options compose:ralt
}

LXQt

Under XOrg:

Consider following the passage below for 'XOrg window sessions', installing setxkbmap first, and then applying the autostart instruction by going to:

Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add

Add a line with your chosen compose key setting, such as:

/usr/bin/setxkbmap -option compose:ralt &
Under Wayland:

Consider applying the guide below, Under Wayland


If the Plasma desktop environment is installed:

Plasma
System Settings \ Hardware \ Input Devices \ Keyboard \ Advanced \ tick "Configure keyboard options" \ tick "Position of Compose key" \ tick selection

The desktop environment's man pages] may give more detailed configurations for the compose key. The following section may also be additionally be useful e.g. where one drops into a tty environment or when switching into a different window manager/compositor than those listed above.

Without set desktop environments

From the following examples, consider the model where the <AltGr> key ('ralt' key) could be assigned for the user only. If a different key is preferred, consider substituting with the key's technical term listed above.

Under XOrg

There are various methods. Consider installing setxkbmap.

$ doas apk add setxkbmap

For XOrg window sessions:

In your window manager's autostart file, consider entering the following:

/usr/bin/setxkbmap -option compose:ralt & 

If there is no austostart file, consider adding that instruction in ~/.xinitrc before the last line(s) being used to launch any window session.

That instruction can also be entered from a shell in order to assign the compose key so as to be in effect only during the login session.

For tty/windowless sessions:

The same setxkbmap instruction could be used at the tty.

To autostart this setting for future sessions:-

  • Consider adding it to a session autostart file; or
  • If there is no autostart file, consider adding it, as proposed directly above for XOrg window sessions, to ~/.xinitrc; or
  • If there is no ~/.xinitrc, consider executing the following:

Create the file (adding the line to ~/.profile instead may be poor practice);

touch ~/.xinitrc

Make ~/.xinitrc executable and read-and-write only by the user:

doas chmod 700 ~/.xinitrc

Then, add the setxkbmap command as indicated above.

Further documentation:

man xkeyboard-config

Under Wayland

Consider various approaches; Sway's method suggested above could be considered first for that compositor.

Option with ~/.profile

Open the file (creating the file first if it doesn't exist), and consider adding:

export XKB_DEFAULT_OPTIONS="compose:ralt"

A list of compose sequences available depend on your keyboard locale.

Further references for this X Keyboard Extension (XKB) include:-

Option using gsettings

Install gsettings-desktop-schemas, if not currently installed:

$ doas apk install gsettings-desktop-schemas

Next:

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

Alternatives

  • Alt codes - Similar to compose keys; briefly, these may involve producing a character by using the <Alt> key in combination with a character's unicode.