Making Copilot Key Work Right: Remapping the Ctrl Key in Modern Linux (Gnome/Wayland)
The latest laptops are coming with new features, such as replacing the normal right Ctrl key with a Copilot key. This key does not send the usual one or two escape codes but instead sends a left Ctrl code. If you are using a modern Linux distribution with Gnome and Wayland, you might wonder how to remap this Copilot key to behave like a regular Ctrl key.
Identifying the Copilot Key
The first step is to identify the Copilot key. You can do this by running the following command:
xevOnce you run this command, a new window will appear. Click on the Copilot key, and you will see output similar to the following:
KeyRelease event, serial 37, synthetic NO, window 0x3400001,
root 0x1d9, subw 0x0, time 1015557, (435,313), root:(1236,546),
state 0x10, keycode 37 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: FalseAs you can see, the keycode is 37, which is the left Ctrl key. However, the keysym is Control_L, which indicates that this is the left Ctrl key. In our case, we need to remap the right Ctrl key to behave like the left Ctrl key.
Remapping the Copilot Key
To remap the Copilot key, we need to create a custom keyboard layout. We can do this using the xkb tool. First, create a new file called copilot in the /usr/share/X11/xkb/symbols directory:
sudo nano /usr/share/X11/xkb/symbols/copilotAdd the following content to the file:
partial alphanumeric_keys
xkb_symbols "copilot" {
include "us(basic)"
key { [ Control_L ] };
}; This will remap the right Ctrl key to behave like the left Ctrl key. Save and close the file.
Next, we need to create a new rules file. Create a new file called copilot in the /usr/share/X11/xkb/rules directory:
sudo nano /usr/share/X11/xkb/rules/copilotAdd the following content to the file:
! option
copilot:switch = +symbols(copilot/copilot)
Save and close the file.
Finally, we need to update the XKB database. Run the following command:
sudo dpkg-reconfigure xkb-dataSelect the copilot rules file and save the changes.
Testing the New Keyboard Layout
To test the new keyboard layout, log out and log back in. Open a terminal and run the following command:
setxkbmap -layout us -variant copilotThis will enable the new keyboard layout. Test the Copilot key by running the following command:
xevClick on the Copilot key, and you should see output similar to the following:
KeyRelease event, serial 37, synthetic NO, window 0x3400001,
root 0x1d9, subw 0x0, time 1015557, (435,313), root:(1236,546),
state 0x10, keycode 64 (keysym 0xffe3, Control_L), same_screen YES,
XLookupString gives 0 bytes:
XFilterEvent returns: FalseAs you can see, the keycode is now 64, which is the right Ctrl key, but the keysym is still Control_L, which indicates that this key now behaves like the left Ctrl key.
- Identify the Copilot key by running the
xevcommand and clicking on the key. - Create a custom keyboard layout using the
xkbtool. - Update the XKB database.
- Test the new keyboard layout by running the
setxkbmapcommand and testing the Copilot key using thexevcommand.
References
- Xorg/Keyboard configuration - ArchWiki
- Remapping right Ctrl key to left Ctrl key - Reddit
- How to remap right Ctrl key to left Ctrl key in Ubuntu 18.04? - Ask Ubuntu
Using Laravel UUIDs in IdeaTypeHints
In this article, we will discuss how to use UUIDs in Laravel projects with the PHPStorm Laravel IdeaTypeHints plugin.
Domain Without 'www' Returning 301 Expected 404 www
This article discusses the issue of a domain without 'www' returning a 301 expected 404 error when 'www' is present.
Calling C# Namespace Python (OSIsoft.AF) in Python using Pythonnet
Learn how to call C# OSIsoft.AF namespace functions in Python using Pythonnet.