Understanding the Scope of xkb Failures
When a keyboard layout works globally but fails in specific applications, the issue is rarely with the kernel-level input handling. Instead, it typically involves how individual applications retrieve their locale settings or interact with the desktop environment's input framework. In Fedora 38 running GNOME, the default input method framework has shifted toward more modular configurations, which can sometimes isolate application-specific settings from the global xkb state.
This isolation means that while your terminal emulator might correctly interpret AltGr combinations for special characters, a web browser or an IDE might not. The root cause usually lies in one of three areas: the application is ignoring the XKBMODEL, XBKLAYOUT, or XKBOPTIONS environment variables; there is a background service intercepting key events before they reach the application; or the application lacks the necessary permissions to query the current X11/Wayland input state.
Verifying Global xkb Configuration
Before diving into application-specific fixes, you must confirm that your global xkb setup is correct. Open a terminal and run the setxkbmap -query command. This utility displays the current model, layout, variant, and options being used by the X server. For example, you should see output similar to:
model: pc105
layout: us,gb
variant: ,
options: grp:alt_shift_toggle
If this output does not match your desired physical keyboard layout and language switches, the problem is systemic, not application-specific. You can temporarily test a different layout using setxkbmap -layout de to see if the issue persists. If it does, the fault lies elsewhere. However, if the change takes effect immediately, you know the underlying xkb engine is functional, pointing the blame at the specific software or its environment.
Checking Input Method Frameworks
GNOME on Fedora 38 uses either IBus or Fcitx as the primary input method framework. These frameworks sit between the xkb layer and the application, processing complex inputs like CJK characters or symbol substitutions. If an application is configured to use a different input method than the system default, or if the framework is frozen, layouts may appear broken.
To diagnose this, check which input method is currently active by looking at the top panel in GNOME or running ibus engine in the terminal. If you are trying to type in a program that does not support the selected input method (for instance, trying to use Fcitx in a GTK2-only application), the keyboard layout will seem unresponsive or incorrect. Ensure that the application supports the current input method by testing it in a simple text editor first. If the issue is isolated to one app, consider switching the input method for that specific session or installing missing input method modules.
For related troubleshooting on password entry fields where input methods often fail, see our guide on Unable to change keyboard layout when inserting password in Linux (Fedora + Gnome).
Resolving Environment Variable Mismatches
Sometimes, an application launches without inheriting the XKB environment variables set during your GNOME session login. This can happen if you launch apps via scripts, cron jobs, or certain system services that do not source the user profile correctly. To fix this, ensure that your .bashrc or .profile files export the necessary variables.
Add lines such as export XKB_DEFAULT_LAYOUT=us and export XKB_DEFAULT_OPTIONS=grp:alt_shift_toggle to your shell configuration file. After saving, restart your session or source the file with source ~/.bashrc. This forces any child process to recognize the correct layout parameters, bridging the gap between the desktop environment and standalone applications.
Debugging Application-Specific Conflicts
If the above steps do not resolve the issue, the application itself may be hardcoding its own input handling logic. Some modern applications bundle their own UI toolkits (like Electron or Qt) that bypass standard X11/Wayland input protocols. In these cases, standard xkb troubleshooting is insufficient.
Try launching the problematic application from the terminal with the GDK_BACKEND=x11 or QT_QPA_PLATFORM=xcb environment variable prepended. For example: GDK_BACKEND=x11 firefox. This forces the application to use the X11 backend instead of Wayland, which can sometimes resolve layout inconsistencies caused by protocol differences. If this works, you can make the change permanent by editing the application's desktop entry file in /usr/share/applications or ~/.local/share/applications to include the backend specification.
Additionally, check if the application has its own internal keyboard shortcut or layout settings. Many developers provide preferences menus where users can override system defaults. Look for sections labeled "Input," "Keyboard," or "Localization" within the application's settings dialog.
System Updates and Package Consistency
Fedora 38 receives frequent updates to its input stack, including libxkbcommon and GNOME Shell components. An outdated package version can introduce regressions in how layouts are parsed. Run sudo dnf update to ensure all input-related packages are synchronized. Pay particular attention to updates for ibus, gnome-control-center, and wayland-utils.
If you recently switched distributions or upgraded from an older Fedora release, residual configuration files from previous versions might conflict with the new xkb standards. Clearing cached input method configurations by deleting ~/.cache/ibus or ~/.config/fcitx can force the system to rebuild its input state from scratch.
Frequently Asked Questions
Why does my keyboard layout work in Firefox but not in VS Code?
This discrepancy usually occurs because VS Code runs on the Electron framework, which may handle input events differently than the native GTK-based Firefox. Ensure that VS Code is updated to the latest version, as older Electron builds often have bugs with Wayland input handling. You can also try launching VS Code with the --disable-gpu flag to rule out hardware acceleration conflicts affecting input rendering.
How do I reset xkb settings to default on Fedora 38?
You can reset your xkb settings by running setxkbmap -layout us in the terminal to revert to a standard US layout. For a deeper reset, delete your custom xkb configuration files in ~/.config/xkb if they exist, and then log out and back into your GNOME session to reload the default system-wide settings.
Can I use different keyboard layouts for different applications?
Yes, GNOME allows per-application input method settings through the Settings menu under Keyboard > Input Sources. However, this feature is primarily designed for switching between languages rather than changing the physical keyboard map. For complex layout changes, you may need to use third-party tools like sxhkd or configure ibus to trigger layout switches based on the active window class.
What causes AltGr keys to stop working in specific programs?
AltGr failures are often caused by the application capturing the Control+Alt key combination for its own shortcuts, preventing it from reaching the xkb layer. Check the application's keybinding settings to see if any shortcuts conflict with AltGr combinations. Alternatively, switch the input method to a simpler mode or disable the input method framework entirely for that specific application.
Is it safe to disable IBus for better keyboard stability?
Disabling IBus can improve keyboard responsiveness for English-language users who do not need complex input methods for CJK characters. However, doing so may break functionality for other users or prevent access to specialized character palettes. It is recommended to keep IBus installed but configure it to start only when needed, or switch to a lighter alternative like Fcitx5 if performance issues persist.