Typing glyphs on Linux: Difference between revisions
(Add entry on xmodmap) |
(Added section on currently available APL keyboards/glyph kits) |
||
Line 277: | Line 277: | ||
} | } | ||
</source> | </source> | ||
== Dedicated APL Keyboards and APL Key Symbol Kits == | |||
Once the keyboard map is configured to one's liking, it may be beneficial (especially for new users learning APL) to have a keyboard with APL symbols. There are a few solutions to this, such as purchasing a dedicated desktop keyboard for APL or, for laptops and desktops, obtaining an APL keyboard decal set: | |||
[https://www.dyalog.com/apl-font-keyboard.htm Dyalog APL desktop keyboard] | |||
[https://www.pckeyboard.com/page/product/USAPLSET Unicomp US APL Keyset] | |||
[https://www.tindie.com/products/24742/ APL Keyboard Sticker Kit] | |||
== References == | == References == |
Revision as of 04:45, 5 November 2021
Since mid-2012, most Linux distributions with X11 have Dyalog APL keyboard support included with the distribution,[1] using xkb
, the X Keyboard Extension.[2]
setxkbmap
The simplest way to set up an APL keyboard on Linux is with the following setxkbmap
command. Enter the following in your terminal emulator of choice:
setxkbmap -layout us,apl -variant ,dyalog -option grp:switch
An explanation:
-layout us,apl
assignsus
(U.S. English) to be the primary layout, whereasapl
is secondary
-option grp:switch
assigns Right Alt to switch to the secondaryapl
layout when it is pressed, otherwiseus
is used
-variant ,dyalog
assigns the Dyalog APL variant to theapl
layout which contains modifiations unique to the Dyalog language (Note the preceding comma)
A full list of keys that can be used to switch layouts is included in /usr/share/X11/xkb/rules/evdev.lst
under the option
category.
Note:
- These changes are not permanent; the user will have to select one of a myriad of methods to run the command on startup. Alternatively, if they use one of the desktop environments listed below, they can follow those instructions.
- If you want to specify a different language, say for United Kingdom, specify
gb
instead ofus
(notuk
)
GNOME
GUI
- Open the Activities menu; this is located in the top-left corner of a default GNOME 3 session (alternatively, use your Super key to open the Activities overlay):
- Search for "startup." When the Startup Applications program is highlighted, press the Enter key to open it:
- Select the Add button on the right-hand side:
- Provide a name, enter your
setxkbmap
command, and click Add when finished:
Terminal
- Navigate to
~/.config/autostart
and create a.desktop
with any name that will help you remember its function. - Add the following to the contents of your file, customizing to suit your needs:
[Desktop Entry] Type=Application Exec=setxkbmap -layout us,apl -variant ,dyalog -option grp:switch Hidden=false NoDisplay=false X-GNOME-Autostart-enabled=true Name[en_US]=apl-keyboard Name=apl-keyboard Comment[en_US]= Comment=
LXDE
- Prepend an
@
to thesetxkbmap
command from above:@setxkbmap -layout us,apl -variant ,dyalog -option grp:switch
- Add it as a line in your user's LXDE
autostart
file, located at:~/.config/lxsession/LXDE/autostart
For Lubuntu versions up to and including 18.04 (before the LXQt split), the location of autostart
is ~/.config/lxsession/Lubuntu/autostart
.
LXQt
GUI
- From your LXQt panel, navigate to Preferences → LXQt Settings → Session Settings; alternatively, enter
lxqt-config-session
in your terminal emulator. You will be greeted with the following window: - Select the
LXQt Autostart
dropdown (it will be highlighted as shown above) and click the Add button to display the following pop-up window: - Provide a name, enter your
setxkbmap
command, and click OK when finished.
Terminal
The above GUI approach merely creates a .desktop
file in the user's ~/.config/autostart
. Create your own file in the autostart
directory whose contents are as follows, to replicate the functionality achieved through the GUI:
[Desktop Entry] Exec=setxkbmap -layout us,apl -variant ,dyalog -option grp:switch Name=apl-keyboard OnlyShowIn=LXQt; Type=Application Version=1.0
MATE
GUI
- Open your MATE menu (in the top-left corner of a default environment) and select Control Center at the bottom of the window:
- Scroll down through the main window, and under the Personal category, select Startup Applications:
- Click the Add button on the right-hand side:
- Provide a name, enter your
setxkbmap
command, and click Add when finished:
Terminal
Navigate to ~/.config/autostart
and create a .desktop
with any name that will help you remember its function.
Add the following to the contents of your file, customizing to suit your needs:
[Desktop Entry] Type=Application Exec=setxkbmap -layout us,apl -variant ,dyalog -option grp:switch Hidden=false X-MATE-Autostart-enabled=true Name[en_US]=apl-keyboard Name=apl-keyboard Comment[en_US]= Comment= X-MATE-Autostart-Delay=0
Wayland
Currently, Wayland uses XKB for keyboards, but they are not modifiable during runtime using e.g. setxkbmap
by default. The keyboard layout must be configured and then the session restarted.
GNOME Tweaks
The Tweaks tool allows configuration beyond the defaults enabled in GNOME.
- Install GNOME Tweaks using apt or dnf, or by searching your distribution's Software Center.
- Start GNOME Tweaks by either:
- Open Keyboard & Mouse Panel and enable "Show Extended Input Sources"
- Open the Additional Layout Options and tick one or more of the options under "Switching to another layout"
- Go to Settings → Region & Language → Add a new input source. Both English (United Kingdom) and English (United States) will have several APL layout options to choose from.
- Restart the session (for example, by logging out and logging in again).
Xfce
Xfce's GUI (Settings Manager
→ Keyboard
→ Layout
) is unable to set up an APL-compatible keyboard. Therefore, we must do it ourselves.
Xfce ships with a utility, xfconf-query, which allows you to manage Xfce's XML configuration files on the command line. Enter the following commands into your terminal:
xfconf-query -c keyboard-layout -n -p '/Default/XkbDisable' -t 'bool' -s 'false'
This enables XKB, allowing us to manage our keyboard layout.
xfconf-query -c keyboard-layout -n -p '/Default/XkbLayout' -t 'string' -s 'us,apl'
Defines the keyboard layout itself. The comma-delimited apl
specifies a second layout group. Make sure you replace us
with the code for your language; a list of these can be found in /usr/share/X11/xkb/rules/evdev.lst
, under the layout
category.
xfconf-query -c keyboard-layout -n -p '/Default/XkbOptions/Group' -t 'string' -s 'grp:win_switch'
This tells Xfce to switch to the APL layout only when the Windows key is pressed. When the Windows key is released, the layout will return to its previous setting. This is incredibly useful as the apl
layouts in XKB do not support Space, Enter, or the arrow keys (among basically all the others). A full list of possible keys for switching between keyboard groups is located in /usr/share/X11/xkb/rules/evdev.lst
, under the option
category.
xfconf-query -c keyboard-layout -n -p '/Default/XkbVariant' -t 'string' -s ',dyalog'
Specifies that the variant applies to the second layout, apl
, due to the preceding comma. The dyalog
variant is unique to Dyalog.
And you're done! Try holding down the Windows key and pressing H on your keyboard — you should see a ∆
.
xmodmap
Modifying the Linux keyboard to support APL keys via xmodmap(1) is possible, but not recommended — it has been superseded by the X keyboard extension (XKB). Generally xmodmap
is best for simple tasks,[3] which APL keyboards often tend not to be. Dyalog APL, for example, has native support for XKB.[2]
For users who understand the pitfalls, an example ~/.Xmodmap
can be found at this GitHub Gist.
Troubleshooting
Gnome catches keystrokes before Dyalog
After upgrading Ubuntu 21.04 (Hirsute Hippo), Gnome catches the keystrokes from the Super key to show the list of applications, before Dyalog can receive it. Changing the shifting key from grp:win_switch
to grp:caps_switch
avoids the issue. Changing it to grp:rctrl_switch
does not work.
Dyalog Overrides Current Keyboard Settings
By default, Dyalog APL overrides the current XKB configuration to use the Meta ("Windows") key as the modifier for entering APL symbols. If the user manages their keyboard configuration manually using the techniques described on this page, this behavior can be quite troublesome.
To run Dyalog in the terminal without overriding ("hijacking") the user keyboard configuration, run dyalog
with the -nokbd
option:
dyalog -nokbd
The following script can be used to launch RIDE, immediately connecting a new Dyalog instance, without changing the xkb settings:
#!/usr/bin/env sh env RIDE_CONNECT=localhost:4502 ride & dyalog +s -q -nokbd RIDE_INIT=SERVE:*:4502
The keyboard layout changing is done by the file at /opt/mdyalog/*/64/unicode/aplkeys.sh
, so changing it changes the behavior (clearing it entirely stops the automatic keyboard layout switching). Note that the file exists for each installed version and is reset on any update, so it may need to be modified multiple times.
APL Keyboard Remains After Dyalog is Closed
Dyalog overrides the current keyboard configuration, as described in this section, but fails to return the user to their previous keyboard configuration on exit. To solve this, create a custom Bash script to save and revert keyboard settings upon exiting Dyalog APL:[4]
#!/usr/bin/sh OLDLAYOUT=$(setxkbmap -query | sed -n 's/^layout://p') OLDVARIANT=$(setxkbmap -query | sed -n 's/^variant://p') OLDOPTION=$(setxkbmap -query | sed -n 's/^options://p') dyalog OLDLAYOUT=$(echo $OLDLAYOUT | sed 's/^$/,/') OLDVARIANT=$(echo $OLDVARIANT | sed 's/^$/,/') setxkbmap -layout $OLDLAYOUT -variant $OLDVARIANT -option -option $OLDOPTION
Settings reverted during X Windows session
Since at least March 2020 there have been issues with setxkbmap
settings being reset without user instruction under the X Windows System.
Below is a script written in Raku that continuously checks for this undesirable reset behavior and puts the intended settings back in place.[5]
#!/usr/bin/env raku # Small script to ensure that APL keyboard layout is still set in xkb settings. # Note that this is a patch for some sort of deranged time-based reset of these # settings that is happening at a lower level of the Xorg-based Linux user experience. # # It's not clear what is causing these resets but this script allows us to more # or less not care about it and get on with our hacking. # # Released under Artistic License by John Longwalker 2020 my $total-checks = 0; sub xkbmap-contains-apl() { $total-checks++; so qx{ setxkbmap -query | grep '^layout:.*\<apl\>' }; # shell-out is easy as usual in a Perl } my $total-resets = 0; sub set-xkbmap-for-apl($key, $verbose) { say "Reset total is now {++$total-resets} -- {DateTime.now}" if $verbose; my $xkb-settings = chomp qx{ setxkbmap -query }; my ($layout, $variant, $options); if $xkb-settings ~~ /^^ "layout:" \s* $<layout>=(<.graph>*) $$/ { $layout = $<layout>.Str; } else { die "Aborting. The xkb settings do not specify any layout:\n$xkb-settings"; } if $xkb-settings ~~ /^^ "variant:" \s* $<variant>=(<.graph>*) $$/ { $variant = $<variant>.Str; } if $xkb-settings ~~ /^^ "options:" \s* $<options>=(<.graph>*) $$/ { $options = $<options>.Str; } $layout = ($layout, 'apl').join(','); $variant = $variant ?? ($variant, 'dyalog') !! 'dyalog'; $options = $options ?? ($options, "grp:$key").join(',') !! "grp:$key"; my $invocation = "setxkbmap -layout $layout -variant $variant -option $options"; say "Invocation: $invocation" if $verbose; qqx{ $invocation }; } # You can use --interval, --key, and -v/--verbose on the command line. sub MAIN(:$interval = 30, :$key = 'switch', :v($verbose) = False) { react { whenever Supply.interval($interval) { set-xkbmap-for-apl($key, $verbose) if not xkbmap-contains-apl; } whenever signal(SIGINT) { say "Reset a total of $total-resets out of $total-checks checks" if $verbose; exit; } } }
Dedicated APL Keyboards and APL Key Symbol Kits
Once the keyboard map is configured to one's liking, it may be beneficial (especially for new users learning APL) to have a keyboard with APL symbols. There are a few solutions to this, such as purchasing a dedicated desktop keyboard for APL or, for laptops and desktops, obtaining an APL keyboard decal set:
References
- ↑ Dyalog Forums. Keyboard setup on Linux. Sep 21, 2010.
- ↑ 2.0 2.1 Geoff Streeter. Supporting APL keyboards on Linux. Dyalog '10.
- ↑ ArchWiki Contributors. xmodmap. 19 July 2021
- ↑ Adám Brudzewsky. Stack Overflow answer. 17 Aug, 2020
- ↑ John Longwalker. 5ab5traction5 blog. Raku to the Rescue: APL Keyboard Keeper. 29 Jun, 2020
APL development [edit] | |
---|---|
Interface | Session ∙ Typing glyphs (on Linux) ∙ Fonts ∙ Text editors |
Publications | Introductions ∙ Learning resources ∙ Simple examples ∙ Advanced examples ∙ Mnemonics ∙ ISO 8485:1989 ∙ ISO/IEC 13751:2001 ∙ A Dictionary of APL ∙ Case studies ∙ Documentation suites ∙ Books ∙ Papers ∙ Videos ∙ APL Quote Quad ∙ Vector journal ∙ Terminology (Chinese, German) ∙ Neural networks ∙ Error trapping with Dyalog APL (in forms) |
Sharing code | Backwards compatibility ∙ APLcart ∙ APLTree ∙ APL-Cation ∙ Dfns workspace ∙ Tatin ∙ Cider |
Implementation | Resources ∙ Open-source ∙ Magic function ∙ Performance ∙ APL hardware |
Developers | Timeline of corporations ∙ APL2000 ∙ Dyalog ∙ IBM ∙ IPSA ∙ STSC |
APL glyphs [edit] | |
---|---|
Information | Glyph ∙ Typing glyphs (on Linux) ∙ Unicode ∙ Fonts ∙ Mnemonics ∙ Overstrikes ∙ Migration level |
Individual glyphs | Jot (∘ ) ∙ Right Shoe (⊃ ) ∙ Up Arrow (↑ ) ∙ Zilde (⍬ ) ∙ High minus (¯ ) ∙ Dot (. ) ∙ Del (∇ )
|