Remapping the greater and less than keys

As you might already know, we've two keyboard layout models one of them having the < and > keys instead of the Delete one.

Considering we've got questions about how to use the <, > and | keys on Slimbook if you've the Delete key layout we've decided to make this tutorial so you can remap the Delete key to function with these symbols.

First of all, you might want to try if you can access these symbols with the following combinations:

Left Shift + Alt Gr + Z ---> '<'

Left Shift + Alt Gr + X ---> '>'

On most keyboard layouts you should be able to use these and now it'd be up to you if you want to replace the Delete key, partially modify the functionality of a key or get used to these combinations instead.

 

 

[Option A] Remapping the whole key

First, you'll need to run xev in a terminal and then press the Delete key (this is the one we're replacing at the moment, you could go for another one if you preffer) and it'll display the keycode for that key. Usually it's 119, but get the one you see on the output. Use Control + C back on the console to exit from this command.

xev

After that we're gonna remap this key so we can use <,> and | with it (They'll be accesed with the following combinations: Key = <, Shift + Key = >, AltGr + Shift + Key = |):

xmodmap -e "keycode 119 = less greater less greater bar brokenbar"

Remember that if your Delete key isn't the keycode 119 or you want to replace another key you'll have to change that keycode.


[Option B] Partially remap a key functionality

First, you'll need to run xev in a terminal and then press the key you want to edit and it'll display the keycode assigned. Use Control + C back on the console to exit from this command.

xev

Once you've the keycode of the key you want to modify, we've to see what the actual functionality is. To make it easier to understand we'll continue the tutorial with the keycode 52, which is the "Z" key, and we'll modify the AltGr functionality. To see what the actual key does, use this command

xmodmap -pke | grep 52

You'll get an output like this "keycode  52 = z Z z Z guillemotleft less"

The one we want to edit here is guillemotleft and we want to convert it to less aswell, so we'll use this command to overwrite the current functionality:

xmodmap -e "keycode 52 = z Z z Z less less"

Now you can use the < key with AltGr + Z.

Final Step: Saving the remap

This will only last for the live session,we advice you to test it out and decide what key fits you the most before proceeding to save it for every boot. To do so, you'll have to add the last command to the /etc/rc.local file (the one with the -e parameter).

sudo nano /etc/rc.local

Then paste above the exit 0 line the command you used to remap the key temporarily on the last step

Finally press Control + X to save it, then press Y/J to confirm and enter to finally save it. Now it will be automatically loaded everytime you boot and if someday you decide to revert it, just open that file again and remove the line.

If when we restart the computer, it has not been successfully remapped we will have to add the command in a file with sh extension in the folder ". config/autostart" which is located in the folder "/home/user", we must add the following lines.

!#/bin/bash
xmodmap -e "keycode 52 = z Z z Z less less"

Then you must give it permissions so that it can be executed at login, we will do it with the following command:

sudo chmod 777 /home/usuario/.config/autostart/archivo.sh

In addition we must create a separate file with the following content, called "file.sh.desktop":

[Desktop Entry]
Type=Application
Exec=/home/usuario/.config/autostart/archivo.sh
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[es]=titulo
Name=/home/usuario/.config/autostart/archivo.sh
Comment[es]=comentario
Comment=comentario
X-GNOME-Autostart-Delay=2

It is important to have the last line, since there are distributions that the remake overwrites with the loading of the system keyboard.

And our keyboard will be configured any way we want.

Remapping the greater and less than keys
Eusebio Giner Slimbook
9 May, 2017
share
archive