Showing posts with label ergonomie. Show all posts
Showing posts with label ergonomie. Show all posts

Tuesday, April 14, 2020

Recommended keyboard settings for Productivity and Usability, for European Programmers

TLDR: setxkbmap -layout us -variant altgr-intl and become a happier programmer.

The case for QWERTY for European Programmers

If you’re working on Unix / Linux, or C based programming languages, it can make sense to switch to the qwerty(us) keyboard layout. Why ?
Unix, C, Perl, Java, and most of programming languages have been conceived on QWERTY keyboards.
So when the designers choose  special characters to use for the language synthax, they simply choose what was easy to access on their own keyboard. This has been historically documented for the vi editor.

To give an example, using an Unix shell you have to type the dot . and slash / symbols quite often to navigate the filesystem. The two keys producing these symbols, are nicely aligned on a QWERTY layout and do not require a key combination to be entered. So you can quickly enter something like ‘../..’ using a single hand.
Now using a QWERTZ layout, like in Germany / Austria, you have the ‘.’ symbol easily accessible, but you need to combine two keys ( Shift + 7 ) to get a ‘/’.
And if you are a poor soul using an AZERTY layout, to get the ‘.’ and ‘/’ symbol you need each time a key combo.
The need of key combos is bad not only for speed (multiple keys to lookup) but also for usability,  as you have to stretch your fingers to reach the key if using a single hand, provoking repetitive strain injury. You might be smiling but this is commonly known amongst Emacs Users, due to the prominent use of commands using Ctrl and Alt combos, and led to the creation of an Emacs Ergonomic wiki.

This goes as well for many symbol commonly used in programming languages, think for instance about the  semicolon ‘;’ for terminating a statement, the ‘[’, and ‘]’ symbols for defining an array, and the backslash ‘\’ for escaping.
All these keys are accessible via a single keypress on qwerty and require key combos on qwertz and azerty. No wonder Linux, Minix and BSD were invented on non-azerty layouts: in France we were still busy typing the path to the source code, when in other parts of the world people already had the file open in their editor.
You don’t need to throw away your existing keyboards when learning the qwerty (us) layout: for a couple of euros, you can find on ebay alternate keys stickers to put on your laptop.

Accessing keys with diacritics with the AltGr International variant

Now if you want to switch to a qwerty keyboard layout, and you’re French or German, you might wonder how to access the characters with diacritics, the é and è of French and ü and ö of German.
Fortunately there is a very clever keyboard variant for the us layout who uses the AltGr key, to make all these keys accessible, just hiding them behind the AltGr key.
Need é ? that’s just AltGr + e away. Needs ç ? That’s just AltGr + , Needs ö ? AltGr +p
See the coolness of that ? You can type all international diacritics in an easy way, and there are even keyboard stickers for that too.

Now how to access to this layout of wonder ?
You can configure the layout and variant in Xorg, in debian/ubuntu that would be entering in /etc/default/keyboard
XKBLAYOUT="us"
XKBVARIANT="altgr-intl"
After restarting the X server, you can check that the settings have been applied with
setxkbmap -print -verbose 10
If using Gnome, you can also set the keyboard layout and variant by changing the schema org.gnome.desktop-inputsources, which will override the desktop-agnostic settings of /etc/default/keyboard.
For this you can either call
dconf write /org/gnome/desktop/input-sources/sources "[('xkb', 'us+altgr-intl')]"
or navigate with the gui tool dconf-settings to org.gnome.desktop-inputsources and set the value there.

If you want to further improve your keyboard layout, you can also have a look at swapping Ctrl and Alt, as described here (French language article) Happy hacking !

Sunday, January 3, 2016

Pinky syndrom ou syndrome du petit doigt sur clavier

La semaine dernière je me suis rendu compte que mon auriculaire de la main gauche était victime du"pinky syndrome" : la partie médiane de l’auriculaire étant particulièrement douloureuse alors que le reste de la main en pleine forme. J'ai rapidement relié ceci a un abus de l'utilisation de l'auriculaire sur mon clavier, j'utilise en effet l'auriculaire de la main gauche a la fois pour acceder à la touche 'shift', à la touche 'Control' et a la touche 'esc'
Quand on travaille avec  Eclipse, Vim et la console Unix, Dieu sait si ces touches sont souvent utilisées !

Comme solution à ce problème j'ai configuré deux options pour mon clavier:
* la touche 'Control' de gauche est échangée avec la touche 'Alt' de gauche, ce qui me force à utiliser le pouce, plus musclé, pour entrer 'Control'.
* la touche 'Caps lock' est replacée par une touche 'Control'.
* j'essaye d'utiliser 'Control-C' pour passer an mode commande dans vim, ce qui évite d'aller chercher une touche bien loin de la position départ de la main.

Les deux premières options se configurent avec
XKBOPTIONS="ctrl:swap_lalt_lctl,caps:ctrl_modifier,terminate:ctrl_alt_bksp"

dans  /etc/default/keyboard

ou avec setxkbmap -model pc105 -layout us -option ctrl:swap_lalt_lctl,caps:ctrl_modifier,terminate:ctrl_alt_bksp en ligne de commande.

Enfin si vous utilisez Gnome 3, il est possible que Gnome écrase ces règlages, il faudra les réintroduire pour Gnome avec:
 dconf write "/org/gnome/desktop/input-sources/xkb-options" "['ctrl:swap_lalt_lctl','caps:ctrl_modifier','terminate:ctrl_alt_bksp']"

NB : on obtient aussi le même résultat en insérant dans le fichier .Xmodmap:

clear control
clear mod1
keycode 37 = Alt_L Meta_L
keycode 64 = Control_L
add control = Control_L Control_R
add mod1 = Alt_L


La liste complète des options d'agencement se trouve dans /usr/share/X11/xkb/rules/base.xml, ces options sont accessibles graphiquement via gnome-tweak-tool.
Le détail du fonctionnement du clavier sous Linux / X11 est expliqué en détail ici.