Adding a custom keyboard layout in GNOME can involve two main approaches: either selecting from a vast array of pre-defined layouts and their variants through the graphical settings or, for advanced users, creating and integrating an entirely new layout file into the system. This guide will walk you through both methods, ensuring you can tailor your keyboard experience to your exact needs.
Understanding Custom Keyboard Layouts in GNOME
Before diving into the steps, it's helpful to understand what "custom" might entail:
- Pre-existing Variants: These are layouts that come pre-installed with your system, often representing different languages, regional spellings, or specialized input methods (e.g., Dvorak, Colemak, various programmer layouts). While not "custom" in the sense of being user-created, they offer a way to customize your typing experience beyond the default QWERTY.
- Truly Custom Layouts (XKB): This refers to layouts you design yourself, defining specific key mappings for every key. This is a more advanced process, involving direct interaction with the X Keyboard Extension (XKB) configuration files.
Method 1: Adding an Available Layout through GNOME Settings
The simplest and most common way to add a different keyboard layout is by using GNOME's built-in settings. This method is suitable for selecting from hundreds of pre-installed layouts and their variants.
Accessing Keyboard Settings
To begin adding or managing keyboard layouts, you'll first navigate through your system preferences:
- Choose System → Preferences → Keyboard. This path will lead you directly to the keyboard configuration options.
- Once there, click the Layouts tab. This tab is your central hub, as it provides all necessary tools to set and customize the keyboard layout from the readily available options.
Adding and Managing Layouts
Follow these steps within the Layouts tab to add a new layout:
- Click the
+
(Add) button usually located at the bottom-left of the Layouts tab. - A dialog will appear, allowing you to search for and select your desired layout. You can browse by language or country, or use the search bar for specific layouts (e.g., "Dvorak").
- Once selected, you might see options for different variants of that layout. Choose the variant that best suits your needs (e.g., "English (US, Dvorak)" or "German (eliminate dead keys)").
- Click
Add
to include the new layout in your list.
You can add multiple layouts and arrange their order by dragging them up or down in the list. The top layout will be the default.
Switching Between Layouts
GNOME provides convenient ways to switch between your added layouts:
- Keyboard Shortcut: By default, you can often switch layouts using Super+Space (Windows key + Spacebar) or Shift+Super+Space for reverse order. You can customize this shortcut in the Keyboard settings under "Switching to next input source" or "Switching to previous input source."
- Top Bar Indicator: A small indicator (often showing a country code or layout name) will appear in the top bar. Clicking on it reveals a menu to select your desired layout.
For more detailed information on GNOME's keyboard settings, refer to the official GNOME Help documentation.
Method 2: Creating and Integrating a Truly Custom XKB Layout (Advanced)
For those who need a layout that isn't pre-defined, creating and integrating your own XKB (X Keyboard Extension) layout is the solution. This process requires a deeper understanding of Linux system configuration and typically involves root privileges.
What is XKB?
XKB is the standard way keyboard layouts are defined and managed on Linux and other Unix-like systems. It's a powerful and flexible system that allows for highly detailed customization of key assignments, modifiers, and behavior. XKB configurations are stored in plain text files, primarily in /usr/share/X11/xkb/
.
Steps to Create and Integrate a New Layout
This is a high-level overview. Specific details can vary slightly between distributions.
-
Design Your Layout:
- Start by understanding an existing layout file. Navigate to
/usr/share/X11/xkb/symbols/
and examine a file likeus
orde
. - Create a new file in this directory (e.g.,
my_layout
) and define your key mappings. This involves specifying what symbol or action each physical key produces. For example,key <AE01> { [ 1, exclam, U2070, U2081 ] };
assigns '1' to the '1' key, '!' with Shift, '⁰' with AltGr, and '₁' with Shift+AltGr. - It's recommended to base your custom layout on an existing one to simplify the process.
- Start by understanding an existing layout file. Navigate to
-
Place the Symbol File:
- Save your newly created symbol file (e.g.,
my_layout
) in the/usr/share/X11/xkb/symbols/
directory. You will need root privileges for this.sudo nano /usr/share/X11/xkb/symbols/my_layout
- Save your newly created symbol file (e.g.,
-
Update XKB Rules:
- For your custom layout to appear in the GNOME settings, you need to inform XKB about its existence. This is done by modifying
evdev.xml
, located in/usr/share/X11/xkb/rules/
. - Open
evdev.xml
with root privileges:sudo nano /usr/share/X11/xkb/rules/evdev.xml
- Locate the
<layoutList>
section and add an entry for your new layout. It should look something like this:<layout> <configItem> <name>my_layout</name> <description>My Custom Layout</description> <languageList> <iso639Id>eng</iso639Id> </languageList> </configItem> <variantList/> </layout>
- Save the file.
- For your custom layout to appear in the GNOME settings, you need to inform XKB about its existence. This is done by modifying
-
Apply the New Layout:
- After saving the changes, you might need to restart your X server or log out and back in for GNOME to pick up the changes.
- Now, when you go to System → Preferences → Keyboard → Layouts tab and click the
+
button, you should find "My Custom Layout" in the list, ready to be added like any other pre-defined layout.
Important Considerations for Advanced Customization:
- Root Privileges: Modifying XKB configuration files requires root access. Exercise caution, as incorrect changes can render your keyboard unusable.
- Backup: Always back up original XKB files before making modifications.
- Documentation: Consult XKB documentation and online tutorials (e.g., from ArchWiki or Ubuntu Wiki) for detailed guidance on creating complex layouts. A good starting point for understanding XKB is the X Keyboard Extension overview.
Tips for Managing Multiple Layouts
If you work with more than one layout, these tips can enhance your experience:
- Per-Window Layout: Some GNOME versions allow you to set a different layout for each window, so switching layouts only affects the active application. Look for this option in the Keyboard settings.
- Visual Indicator: Ensure the keyboard indicator is visible in your top bar to easily see which layout is currently active.
- Experiment: Don't hesitate to experiment with different layouts and variants. You can always remove layouts you don't use.
Basic vs. Advanced Keyboard Layout Customization in GNOME
Here's a quick comparison of the two approaches:
Feature/Method | Basic Customization (GNOME Settings) | Advanced Customization (XKB Configuration) |
---|---|---|
Purpose | Select from available layouts, manage variants, set switching options. | Create entirely new key mappings, modify system-level layout definitions. |
User Level | All users, beginner-friendly. | Advanced users, developers, system administrators. |
Tools Used | GNOME Settings application. | Text editor, terminal, XKB configuration files (.xkb , evdev.xml ). |
Permissions | Standard user permissions. | Root privileges required for modifying system XKB files. |
Flexibility | Limited to pre-defined layouts and their variants. | Full control over key assignments, modifiers, and symbols. |
Risk | Low; easily reversible changes within settings. | Higher; incorrect modifications can lead to unusable keyboard. |