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

From Alpine Linux
No edit summary
 
(38 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Delete|  Updated page is now in main wiki: [[Compose key]]. 
This page version is no longer updated. }}
{{TOC right}}
{{TOC right}}


A '''compose key''' may be assigned to quickly produce certain characters from a keyboard.  For example:
A [https://en.wikipedia.org/wiki/Compose_key compose key] may be assigned to quickly produce certain characters from a keyboard.  These could include a letter with an accent such as '''é'''a letter with a [https://en.wikipedia.org/wiki/Diacritic diacritic] such as '''ç''';  or various symbols and [https://en.wikipedia.org/wiki/Emoji emojis] such as '''≥''', '''☺''', etc.
* a letter with an accent such as '''é'''
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''' on a given installation, depending on the configuration method chosen, one may obtain the character "'''é'''" by pressing the following three characters one after another:
* a letter with a diacritic such as '''ç'''
* 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> = é
Other examples may include:
Other examples may include:
  <AltGr> + <,> + <c> = ç
  <AltGr> + <,> + <c> = ç
  <AltGr> + <c> + <c> = č
  <AltGr> + <c> + <c> = č
Line 16: Line 15:
  <AltGr> + <=> + <E> = €
  <AltGr> + <=> + <E> = €
  <AltGr> + <-> + <L> = £
  <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:
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>+<;> = :  
  Hold<Shift>+<;> = :  
Therefore, consider the following example:
Therefore, consider the following example:
  <AltGr> + <:> + <)> = ☺   
  <AltGr> + <:> + <)> = ☺   
 
Depending on your layout, since additionally the left bracket ')' on some layouts is created by shifting the "zero" key, one may need to do as follows:
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> = ☺
  <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:
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> = ä
  <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:
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> = ä
  <AltGr> + Hold<Shift>+<'> + <a> = ä
Consider a listing of [https://sheet.shiar.nl/digraphs/xorg combinations under Xorg].
Consider a listing of [https://sheet.shiar.nl/digraphs/xorg combinations under Xorg].
== Assign the compose key ==
== Assign the compose key ==
 
{{Todo|
{{Todo|<nowiki>
* Elaborate with alternative methods, including [https://github.com/kragen/xcompose Xcompose], {{pkg|xmodmap}};
 
* Document assigning compose key for all users.
* Elaborate on alternative methods, including 'Xcompose'
Contributions welcome.}}
* Document assigning the compose key for all users.
Decide what compose key you will choose.  Then, you may need to refer to it in the instructions below by its technical term listed in italics, as follows:-
Contributors welcome.}}
* <LWIN> or <Left Windows> key a.k.a. the 'Windows' or 'Logo' key on the left: <i>lwin</i>
 
* <RWIN> or <Right Windows> key (it exists on some keyboards and is not to be confused with the 'Windows' key on the left):  <i>rwin</i>
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:-
* <AltGr> key a.k.a. the <Alt> key on the right:  <i>ralt</i>
 
* <Alt> key on the left:  <i>lalt</i>
* <LWIN> or <Left Windows> key a.k.a. the 'Windows' or 'Logo' key on the left: 'lwin'
* <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 <LWIN>/'Logo'/<Left Windows> key: <i>menu</i>
* <RWIN> or <Right Windows> key (it exists on some keyboards and is not to be confused with the 'Windows' key on the left):  'rwin'
* <Caps Lock> key:  <i>caps</i>
* <AltGr> key a.k.a. the <Alt> key on the right:  'ralt'
* <Pause> key:  <i>paus</i>
* <Alt> key on the left:  'lalt'
* <Print Scrn> key:  <i>prsc</i>
* <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'
* <Scroll Lock> key:  <i>sclk</i>
* <Caps Lock> key:  'caps'
* <Right Control> key:  <i>rctrl</i>
* <Pause> key:  'paus'
* <Left Control> key:  <i>lctrl</i>
* <Print Scrn> key:  'prsc'
* <Scroll Lock> key:  'sclk'
* <Right Control> key:  'rctrl'
* <Left Control> key:  'lctrl'
 
=== 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 was installed via <code>setup-desktop</code>, one should first consider assigning the compose key through one of the desktop's <i>"Settings"</i> modules and then, specifically, seeking those relating to <i>"Keyboard"</i> or, alternative, an <i>"autostart"</i> module:-
 
==== [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 <i>Settings</i> \ Settings icon \ Keyboard \ enable <i>Compose Key</i> \ select the <i>Compose Key</i>
 
==== [https://xfce.org XFCE] ====
==== [https://xfce.org XFCE] ====
  Applications \ Settings \ Settings Editor \  Channel "keyboard-layout" \ XkbOptions \ Compose \ type <code>compose:ralt</code> or otherwise for your preferred compose key
  Applications \ Settings \ Settings Editor \  Channel <i>keyboard-layout</i> \ XkbOptions \ Compose \ type <code>compose:ralt</code> 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 click 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 (<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>):
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" {
   [...]
   [...]
   xkb_options compose:ralt
   xkb_options compose:ralt
  }
  }
==== [https://github.com/lxqt/lxqt/wiki LXQt] ====
==== [https://github.com/lxqt/lxqt/wiki LXQt] ====
===== Under XOrg: =====
===== LXQt 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:
You may require installing {{Pkg|setxkbmap}} first; then, consider using the autostart instruction:
  Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add
  Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add
 
Where prompted under that module, add a line specifying your chosen compose key setting.  For example:
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, regarding window sessions for [[Compose_key#section=15|under Wayland in general]].


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] =====
 
  System Settings \ Hardware \ Input Devices \ Keyboard \ Advanced \ tick <i>Configure keyboard options</i> \ tick <i>Position of Compose key</i> \ tick selection
  System Settings \ Hardware \ Input Devices \ Keyboard \ Advanced \ tick "Configure keyboard options" \ tick "Position of Compose key" \ tick selection
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 (<i>ralt</i> 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 autostart file, consider adding that instruction into <code>~/.xinitrc</code> before the last line(s) that is/are being used to launch any window session.  
If there is no autostart file, consider adding that instruction in <code>~/.xinitrc</code> before the last line(s) that is/are 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.
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: =====
===== For tty/windowless sessions: =====
The same '''setxkbmap''' instruction could be used at the tty.   
The same '''setxkbmap''' instruction could be used at the tty.   
To autostart this setting for future sessions:-
To autostart this setting for future sessions:-
* Consider adding it to a session autostart file; or
* 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 <code>~/.xinitrc</code>;  or
* If there is no autostart file, consider adding it, as proposed directly above for XOrg window sessions, to <code>~/.xinitrc</code>;  or
* If there is no <code>~/.xinitrc</code>, consider executing the following:
* If there is no <code>~/.xinitrc</code>, consider executing the following:
<blockquote>
<blockquote>
Create the file (adding the line to <code>~/.profile</code> instead may be poor practice);  
Create the file (adding the line to <code>~/.profile</code> instead may be poor practice);  
{{Cmd| touch ~/.xinitrc }}
{{Cmd| touch ~/.xinitrc }}
Make <code>~/.xinitrc</code> executable and read-and-write only by the user:   
Make <code>~/.xinitrc</code> executable and read-and-write only by the user:   
{{Cmd|  doas chmod 700 ~/.xinitrc }}
{{Cmd|  doas chmod 700 ~/.xinitrc }}
 
Then, add lines to instruct the file to be read with the default <code>sh</code> interpreter; plus the '''setxkbmap''' command as indicated above:
Then, add the '''setxkbmap''' command as indicated above.
<pre>
#!/bin/sh
/usr/bin/setxkbmap -option compose:ralt &
</pre>
</blockquote>
</blockquote>


Further documentation:
Further documentation:
{{Cmd| man xkeyboard-config }}
{{Cmd| man xkeyboard-config }}
==== 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], including:-
 
===== Option with ~/.profile =====
===== Option with ~/.profile =====
<blockquote>
Open the file (creating the file first if it doesn't exist), and consider adding:
Open the file (creating the file first if it doesn't exist), and consider adding:
 
<pre>
  export XKB_DEFAULT_OPTIONS="compose:ralt"
  export XKB_DEFAULT_OPTIONS="compose:ralt"
 
</pre>
</blockquote>
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].


Further references for this X Keyboard Extension (XKB) include:-
Further references for this X Keyboard Extension (XKB_DEFAULT_OPTIONS) include:-
* [https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Config.html Xorg - XKB configuration.]
* [https://www.x.org/releases/current/doc/xorg-docs/input/XKB-Config.html Xorg - XKB configuration.]
* [https://wiki.archlinux.org/title/X_keyboard_extension Archwiki - X Keyboard extension.]
* [https://wiki.archlinux.org/title/X_keyboard_extension Archwiki - X Keyboard extension.]
===== Option using gsettings =====
===== Option using gsettings =====
Install {{pkg|gsettings-desktop-schemas}}, if not currently installed:
<blockquote>
 
Install {{pkg|gsettings-desktop-schemas}}, if not installed:
{{Cmd| $ doas apk install gsettings-desktop-schemas }}
{{Cmd| $ doas apk install gsettings-desktop-schemas }}
Next:
Next:
{{Cmd| $ gsettings set org.gnome.desktop.input-sources xkb-options "[\'compose:ralt\']" }}
{{Cmd| $ gsettings set org.gnome.desktop.input-sources xkb-options "[\'compose:ralt\']" }}
</blockquote>


=== Alternatives ===
=== Alternatives ===
* [https://en.wikipedia.org/wiki/Alt_code Alt codes] - Similar to compose keys;  briefly, these may involve producing a character by using the <Alt> key in combination with a character's [https://home.unicode.org/ unicode].
* [https://en.wikipedia.org/wiki/Alt_code Alt codes] - Similar to compose keys;  briefly, this could involve producing a character by using the <Alt> key in combination with a character's [https://home.unicode.org/ unicode].

Latest revision as of 22:34, 19 July 2025

This material is proposed for deletion ...

Updated page is now in main wiki: Compose key.

This page version is no longer updated.

(Discuss)
Make sure no other pages link here and check the page's history before deleting.


A compose key may be assigned to quickly produce certain characters from a keyboard. These could include a letter with an accent such as é; a letter with a diacritic such as ç; or various 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 on a given 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 created 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 with alternative methods, including Xcompose, xmodmap;
  • Document assigning compose key for all users.
Contributions welcome.


Decide what compose key you will choose. Then, you may need to refer to it in the instructions below by its technical term listed in italics, 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 <LWIN>/'Logo'/<Left Windows> 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 was installed via setup-desktop, one should first consider assigning the compose key through one of the desktop's "Settings" modules and then, specifically, seeking those relating to "Keyboard" or, alternative, an "autostart" module:-

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 click 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

LXQt under XOrg:

You may require installing setxkbmap first; then, consider using the autostart instruction:

Preferences \ LXQt Settings \ Session Settings \ Autostart \ Add

Where prompted under that module, add a line specifying your chosen compose key setting. For example:

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

Consider applying the guide below, regarding window sessions for under Wayland in general.

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 autostart file, consider adding that instruction into ~/.xinitrc before the last line(s) that is/are 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 lines to instruct the file to be read with the default sh interpreter; plus the setxkbmap command as indicated above:

 #!/bin/sh
 /usr/bin/setxkbmap -option compose:ralt &

Further documentation:

man xkeyboard-config

Under Wayland

Consider various approaches, including:-

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_DEFAULT_OPTIONS) include:-

Option using gsettings

Install gsettings-desktop-schemas, if not 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, this could involve producing a character by using the <Alt> key in combination with a character's unicode.