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

From Alpine Linux
No edit summary
No edit summary
Line 40: Line 40:




* Elaborate on alternative methods, including [https://github.com/kragen/xcompose Xcompose]
Elaborate on alternative methods, including '''Xcompose'''; document assigning the compose key for all users.
 
* Document assigning the compose key for all users.


Contributors welcome.}}</nowiki>}}
Contributors welcome.}}</nowiki>}}
Line 93: Line 91:
===== Under XOrg: =====
===== Under XOrg: =====


Consider following the [[XOrg window sessions|passage below for 'XOrg window sessions']], installing 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
Line 113: Line 111:
  System Settings \ Hardware \ Input Devices \ Keyboard \ Advanced \ tick "Configure keyboard options" \ tick "Position of Compose key" \ tick selection
  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.
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.




Line 123: Line 121:
==== Under XOrg ====
==== Under XOrg ====


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


{{Cmd| $ doas apk add setxkbmap }}
{{Cmd| $ doas apk add setxkbmap }}
Line 129: Line 127:


===== 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:


Line 135: Line 134:




If there is no austostart file, consider adding that instruction in `~/.xinitrc` 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.  


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.
Line 142: Line 141:
===== 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:-
Line 148: Line 147:
* 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 `~/.xinitrc`;  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 `~/.xinitrc`, consider executing the following:
* If there is no <code>~/.xinitrc</code>, consider executing the following:


Create the file (adding the line to `~/.profile` 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 `~/.xinitrc` 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 the setxkbmap command as indicated above.
Then, add the '''setxkbmap''' command as indicated above.


Further documentation:
Further documentation:
Line 172: Line 171:




===== Option with `~/.profile` =====
===== Option with ~/.profile =====


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:
Line 188: Line 187:
===== Option using gsettings =====
===== Option using gsettings =====


Install gsettings-desktop-schemas, if not currently installed:
Install {{pkg|gsettings-desktop-schemas}}, if not currently installed:


{{Cmd| $ doas apk install gsettings-desktop-schemas }}
{{Cmd| $ doas apk install gsettings-desktop-schemas }}

Revision as of 05:45, 14 July 2025

Compose key

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:

<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 `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\']"