Sample Header Ad - 728x90

Unix & Linux Stack Exchange

Q&A for users of Linux, FreeBSD and other Unix-like operating systems

Latest Questions

0 votes
1 answers
91 views
Swapping Ctrl, Win, and Alt in MX Linux (Xfce) – Issue with Alt Modifier
I'm using MX Linux with Xfce and trying to swap three keys: - Ctrl → Win (Super) - Win → Alt - Alt → Ctrl Swapping two keys at a time works using `setxkbmap`, for example: ```bash setxkbmap -option ctrl:swap_lalt_lctl ``` However, if I try to add a second swap, like: ```bash setxkbmap -option ctrl:s...
I'm using MX Linux with Xfce and trying to swap three keys: - Ctrl → Win (Super) - Win → Alt - Alt → Ctrl Swapping two keys at a time works using setxkbmap, for example:
setxkbmap -option ctrl:swap_lalt_lctl
However, if I try to add a second swap, like:
setxkbmap -option ctrl:swap_lalt_lctl,altwin:swap_alt_win
I end up with a repetition of the same key instead of a clean three-way swap. ### Attempted Solution I created a custom XKB symbols file:
xkb_symbols "ctrl_win_alt_swap" {
    include "us"  // Keep the default US layout
    key  { [ Super_L ] };  // Left Ctrl → Left Win
    key  { [ Alt_L ] };    // Left Win → Left Alt
    key  { [ Control_L ] }; // Left Alt → Left Ctrl
};
I apply this with:
setxkbmap -layout custom -variant ctrl_win_alt_swap
The remapping works, except for one issue: - Pressing **Alt alone** produces Ctrl, which is expected. - Pressing **Alt in combination with another key** results in **Ctrl+Alt**, instead of just Ctrl. Why does this happen, and how can I properly swap Ctrl, Win, and Alt without modifier conflicts?
igm2103 (1 rep)
Feb 2, 2025, 10:09 PM • Last activity: Feb 4, 2025, 06:36 PM
0 votes
1 answers
82 views
How do I create a per user xkb keymap?
It is possible to create your own custom xkb maps by adding files to /usr/share/X11/xkb/symbols. However, this directory is managed my dpkg and requires root access. Is there a way of placing a keymap under somewhere $HOME where setxkbmap file find it? Question closed on SO as not about programming:...
It is possible to create your own custom xkb maps by adding files to /usr/share/X11/xkb/symbols. However, this directory is managed my dpkg and requires root access. Is there a way of placing a keymap under somewhere $HOME where setxkbmap file find it? Question closed on SO as not about programming: https://stackoverflow.com/questions/79204214/how-do-i-create-a-per-user-xkb-keymap
Att Righ (1412 rep)
Nov 19, 2024, 04:59 PM • Last activity: Nov 20, 2024, 12:08 PM
1 votes
1 answers
7792 views
WARNING: Running setxkbmap against an XWayland server
I'm using Fedora 37, tilix terminal emulator with fish shell. Whenever I open a terminal, I get the warning ``` WARNING: Running setxkbmap against an XWayland server ``` How come? How to avoid it?
I'm using Fedora 37, tilix terminal emulator with fish shell. Whenever I open a terminal, I get the warning
WARNING: Running setxkbmap against an XWayland server
How come? How to avoid it?
tsorn (159 rep)
Apr 30, 2023, 07:48 PM • Last activity: Aug 27, 2024, 04:02 AM
0 votes
0 answers
40 views
Prevent keyboard layout from being changed
For some reason my keyboard layout occasionally switches to another language. Is there a way to prevent other software from changing my keyboard layout? I can run... setxkbmap de ...to fix it, but it would be nice if it would just stay this way. Linux Mint, Mate, i3wm
For some reason my keyboard layout occasionally switches to another language. Is there a way to prevent other software from changing my keyboard layout? I can run... setxkbmap de ...to fix it, but it would be nice if it would just stay this way. Linux Mint, Mate, i3wm
Ocean (278 rep)
Jun 10, 2024, 07:40 PM • Last activity: Jun 11, 2024, 09:18 AM
0 votes
1 answers
92 views
Remap Right Alt to Backspace
As the title says how can I remap Right Alt to Backspace? I am on X11 I am aware that something can be done using `setxkbmap` but I not aware of the command for my particular case.
As the title says how can I remap Right Alt to Backspace? I am on X11 I am aware that something can be done using setxkbmap but I not aware of the command for my particular case.
Mach50 (1 rep)
May 1, 2024, 09:24 PM • Last activity: May 1, 2024, 10:35 PM
1 votes
1 answers
230 views
`setxkbmap kr` not doing anything?
I'm trying to add a configuration to my multilingual setup on my ArchLinux desktop, but Korean doesn't seem to do anything, despite it being listed under `setxkbmap`. How do I set it up similarly to other languages? So far, what I've been doing is basically this: ```sh # For US International: setxkb...
I'm trying to add a configuration to my multilingual setup on my ArchLinux desktop, but Korean doesn't seem to do anything, despite it being listed under setxkbmap. How do I set it up similarly to other languages? So far, what I've been doing is basically this:
# For US International:
setxkbmap -layout us -variant intl

# Or for just US:
setxkbmap us
Why doesn't this work:
setxkbmap kr
Am I missing a (Pacman/AUR) package?
psygo (233 rep)
Jan 8, 2024, 08:42 PM • Last activity: Jan 12, 2024, 06:28 PM
1 votes
1 answers
72 views
XKB spec says 63 levels max per type. For me it's 8. What am I doing wrong?
X.org version: 1.21.1.7 Distribution: Kubuntu 23.04 I duplicated the included `EIGHT_LEVEL_ALPHABETIC_LEVEL_FIVE_LOCK` type, inserted an additional level as `Level1`, and shifted all existing levels by +1. The highest level was then `Level9`. Running `setxkbmap` (regardless of specified layout, sinc...
X.org version: 1.21.1.7
Distribution: Kubuntu 23.04 I duplicated the included EIGHT_LEVEL_ALPHABETIC_LEVEL_FIVE_LOCK type, inserted an additional level as Level1, and shifted all existing levels by +1. The highest level was then Level9. Running setxkbmap (regardless of specified layout, since no xkb_symbols uses this type) yields > Error loading new keyboard description Then, if I comment out all references to Level9 in that type, it works. Diff here: https://github.com/yue-dongchen/Neo2-QWERTY/commit/66097e14be4aa4012c8f54aaa4ff5739bd559327 --- Answer to my previous question — *How many levels can XKB accomodate?* — which quotes **63 levels** from the XKB specification. **Edit:** Though I suppose it doesn't really matter, since the layout I'm seeking to modify really only uses the former 7 levels. But it would still be nice to know if I encounter the need in future.
Dongchen (43 rep)
Dec 13, 2023, 07:10 AM • Last activity: Dec 14, 2023, 01:00 PM
1 votes
0 answers
98 views
xkb: how can `modifier_map` be completely replaced
When defining a custom keyboard layout with xkb, how can I completely override a modifier? E.g. when I have ``` xkb_keymap { xkb_keycodes { include "evdev+aliases(qwerty)" }; xkb_types { include "complete" }; xkb_compat { include "complete" }; xkb_geometry { include "pc(pc105)" }; xkb_symbols { incl...
When defining a custom keyboard layout with xkb, how can I completely override a modifier? E.g. when I have
xkb_keymap {
    xkb_keycodes  { include "evdev+aliases(qwerty)" };
    xkb_types     { include "complete"      };
    xkb_compat    { include "complete"      };
    xkb_geometry  { include "pc(pc105)"     };
    xkb_symbols   {
        include "pc+us"
        override modifier_map Mod4 { ,  };
    };
};
I expect that Mod4 is only generated for the two "Alt" keys. But
xkbcomp test :0 && xkbcomp :0 generated
grep Mod4 generated
shows that old mappings (from pc105) are still applied
modifier_map Mod4 {  };
    modifier_map Mod4 {  };
    modifier_map Mod4 {  };
    modifier_map Mod4 {  };
    modifier_map Mod4 {  };
    modifier_map Mod4 {  };
ensc (221 rep)
Nov 11, 2023, 02:11 PM
0 votes
1 answers
272 views
How to translate setxkbmap to xinitrc config
I am setting my keyboard layout using this command on every startup: ``` setxkbmap us,cz -variant ,ucw -option grp:caps_switch ``` How can I write this configuration in to `xinitrc` file so xserver loads it natively ? Thank you for help
I am setting my keyboard layout using this command on every startup:
setxkbmap us,cz -variant ,ucw -option grp:caps_switch
How can I write this configuration in to xinitrc file so xserver loads it natively ? Thank you for help
Jan Černý (1723 rep)
Sep 24, 2023, 01:31 PM • Last activity: Sep 24, 2023, 05:51 PM
1 votes
1 answers
594 views
Map <C-S-A-hjkl> to Arrow Keys with XKB Map
I'm trying to also have access to my arrow keys from the default Vim h j k l . Since Ctrl Shift Alt seems to be a rare key combo, I was thinking about using that. How would I do that using `setxkbmap` (or another equivalent tool)?
I'm trying to also have access to my arrow keys from the default Vim hjkl. Since CtrlShiftAlt seems to be a rare key combo, I was thinking about using that. How would I do that using setxkbmap (or another equivalent tool)?
psygo (233 rep)
Jun 1, 2023, 05:17 PM • Last activity: Jun 13, 2023, 11:31 AM
1 votes
1 answers
100 views
setxkbmap and xmodmap often stop working
I have a script to: 1. Set the keyboard layout to include accents 2. Set capslock as mod when held 3. Set capslock as escape when pressed It looks like this: setxkbmap -rules evdev -model evdev -layout us -variant altgr-intl & sleep 1 xmodmap ~/.Xmodmap & sleep 1 killall -q xcape & xcape -e "Hyper_L...
I have a script to: 1. Set the keyboard layout to include accents 2. Set capslock as mod when held 3. Set capslock as escape when pressed It looks like this: setxkbmap -rules evdev -model evdev -layout us -variant altgr-intl & sleep 1 xmodmap ~/.Xmodmap & sleep 1 killall -q xcape & xcape -e "Hyper_L=Escape" & Those sleep are there because otherwise it doesn't work well. I don't understand why and I'd love to. In addition to that, sometimes the escape part of it just stops working, and I have to relaunch the script. I'm not exactly sure what triggers this but it is annoying.
indeedwatson (13 rep)
Jun 4, 2023, 01:34 PM • Last activity: Jun 4, 2023, 06:08 PM
0 votes
2 answers
392 views
Map Caps Lock to AltGr and Escape - why does setxkbmap silence xcape daemon?
I'm on a 20.04 Ubuntu machine. I've been trying to use a combination of ```setxkmap``` and ```xcape``` to map AltGr and escape onto my caps-lock key, where a *quick key press* acts as **escape** and a *longer key press* acts as **AltGr**. I believed the desired behavior could be achieved by executin...
I'm on a 20.04 Ubuntu machine. I've been trying to use a combination of
and
to map AltGr and escape onto my caps-lock key, where a *quick key press* acts as **escape** and a *longer key press* acts as **AltGr**. I believed the desired behavior could be achieved by executing the following:
$ setxkbmap -option lv3:caps_switch
$ xcape -e 'Caps_Lock=Escape' -t 300
Once the setxkbmap command is executed however, the xcape process/daemon no longer makes caps-lock act as escape when tapped. I'm not entirely sure why since the **xcape process is still running**, so I might just simply be oblivious to how setxkbmap works (I tried executing the commands in a different order, with the same result). How would I go about achieving the desired behavior? Why does setxkbmap 'silence' the xcape daemon regardless of whether I execute xcape before/after executing the setxkbmap command?
DBJ (1 rep)
Apr 7, 2023, 11:03 AM • Last activity: Apr 7, 2023, 03:59 PM
1 votes
0 answers
529 views
How to set keyboard layout and keep configuration?
I changed from gnome to i3wm and now everytime I log in to my computer the keyboard layout is set to english (my keyboard is spanish). I was able to change it with this command but just for the current session. ``` setxkbmap -layout latam ``` I tried adding this configuration to `~/.zsh_profile` and...
I changed from gnome to i3wm and now everytime I log in to my computer the keyboard layout is set to english (my keyboard is spanish). I was able to change it with this command but just for the current session.
setxkbmap -layout latam
I tried adding this configuration to ~/.zsh_profile and ~/.profile but it didn't work.
Luis Ur&#225;n (11 rep)
Mar 25, 2023, 11:04 PM • Last activity: Mar 29, 2023, 01:05 PM
0 votes
0 answers
210 views
xkb swap backslash and return: how to deal with shift?
I'm trying to swap Enter and Backslash key. I figured out how to swap them when Shift is not involved: key {[ backslash ]}; key {[ Return ]}; However, when shift is down, by pressing Enter I got "\", whereas I would like to have "|" there. And vice versa, by pressing Backslash I got "|", whereas I w...
I'm trying to swap Enter and Backslash key. I figured out how to swap them when Shift is not involved: key {[ backslash ]}; key {[ Return ]}; However, when shift is down, by pressing Enter I got "\", whereas I would like to have "|" there. And vice versa, by pressing Backslash I got "|", whereas I would like to have Enter (just as without shift). How to define keys for Shift? Any help would be greatly appreciated!
Maciek (3 rep)
Dec 13, 2022, 09:14 PM
7 votes
1 answers
5227 views
How to use setxkbmap to map keys permanently?
I'm currently using `xmodmap` to remap some keys, keeping my configuration in a `.Xmodmap` file, but every time I boot my laptop, or my screen locks, the customization is lost and I have to run `xmodmap ~/.Xmodmap` once again, even though I set the command to execute on startup and in the `~/.xinitr...
I'm currently using xmodmap to remap some keys, keeping my configuration in a .Xmodmap file, but every time I boot my laptop, or my screen locks, the customization is lost and I have to run xmodmap ~/.Xmodmap once again, even though I set the command to execute on startup and in the ~/.xinitrc file too. I've rummaged about forums looking for information on setxkbmap, but I can't really understand what's going on, and have trouble trying to remap some keys. For example, the key on the right of my Right Alt key, when pressed under xev, looks like this: > KeyPress event, serial 37, synthetic NO, window 0x2600001,
root 0x6a8, subw 0x0, time 14892208, (674,389), root:(848,553),
state 0x0, keycode 97 (keysym 0x0, NoSymbol), same_screen YES,
XLookupString gives 0 bytes:
XmbLookupString gives 0 bytes:
XFilterEvent returns: False
1 - So we have keycode 97 and keysym NoSymbol. How would I map that to be Right Control using setxkbmap? 2 - Also, how can I remap the Ctrl + Arrow Keys to work like Home / End / PgUp / PgDown? Most importantly, I want to make these changes **permanent**. 3 - Lastly, is there any comprehensive content or documentation about this program out on the web? Thank you very much for your time and attention.
Lucas (73 rep)
Dec 6, 2022, 10:39 PM • Last activity: Dec 6, 2022, 11:24 PM
0 votes
1 answers
1264 views
How to (permently) set keyboard mappings using setxkbmap? It gives an error
I am diving into custom keyboard mappings. Basically, I just want to switch the Alt_L with Ctrl_L and Alt_R with Ctrl_R (kind of like Command on MacBooks). In the file `/usr/share/X11/xkb/symbols/ctrl` there is already a definition for a swap of Alt_L with Ctrl_L (So adding a definition for the oppo...
I am diving into custom keyboard mappings. Basically, I just want to switch the Alt_L with Ctrl_L and Alt_R with Ctrl_R (kind of like Command on MacBooks). In the file /usr/share/X11/xkb/symbols/ctrl there is already a definition for a swap of Alt_L with Ctrl_L (So adding a definition for the opposite side should be a piece of cake) called swap_lalt_lctl.  However, when I type the following:
setxkbmap -layout us -option ctrl:swap_lalt_lctl
in the terminal, I receive the following error:
Error loading new keyboard description
I have already spent several hours googling and trying different things to resolve the problem, like: sudo, clearing cache, rebooting, explicitly stating machine info in command, but nothing seems to work. Strange thing is that setxkbmap -layout us works fine and also setxkbmap with other options seems to be working.  It appears that it affects only the ctrl: options. If somebody could help me out, suggest some solution paths, I would be really grateful. Oh, and lsb_release -a gives:
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.1 LTS
Release:	22.04
Codename:	jammy
___ Without taking a deep dive into xkb, the closest I get is setting the "Ctrl is mapped to Alt, Alt to Win" option in the Gnome-Tweaks tool.
vshas (109 rep)
Nov 9, 2022, 10:15 PM • Last activity: Nov 11, 2022, 12:54 PM
1 votes
0 answers
105 views
Is there an API to query setxkbmap's current layout?
A bit related to [this previous question of mine](https://unix.stackexchange.com/questions/723777/how-do-you-use-keyboard-driven-programs-with-non-latin-alphabet-keyboards), I wonder if there's a way to query what is the current layout. Say I have run ```bash setxkbmap -layout it,ru -variant ,phonet...
A bit related to [this previous question of mine](https://unix.stackexchange.com/questions/723777/how-do-you-use-keyboard-driven-programs-with-non-latin-alphabet-keyboards) , I wonder if there's a way to query what is the current layout. Say I have run
setxkbmap -layout it,ru -variant ,phonetic -option 'grp:caps_toggle'
and that I've presset CapsLock a few times. How can I tell programmatically what of 2 states I'm in? Interactively I can simply type some characters to check, but I want to do it programmatically, so I can have that state printed in a status bar or something. --- I was also thinking of some hack, like synthetically hitting CapsLockfCapsLockf, and then checking whether the output is фf or , which would tell me the current layout is it or ru respectively. [xdotool seemed the correct tool for this](https://unix.stackexchange.com/questions/267704/command-to-simulate-keyboard-input) , but unfortunately Caps_Lock corresponds to the _function_ of the ordinary CapsLock key, and not to what the setxkbmap command above has set it to, so this
xdotool key Caps_Lock f Caps_Lock f
results in Ff regardless of what layout is active.
Enlico (2258 rep)
Nov 6, 2022, 08:25 AM • Last activity: Nov 6, 2022, 08:49 AM
1 votes
0 answers
207 views
Adding a single keycode to the existing XKB configuration
I have a MECHREV laptop, /sys/class/dmi/id/product_name "Jiaolong Series GM5ZG0O". Its keyboard has a button for toggling trackpad on/off. However this key emits keycode 93 which is not mapped to anything in /usr/share/X11/xkb/keycodes/evdev which is the auto-configuration Xorg chooses. I don't want...
I have a MECHREV laptop, /sys/class/dmi/id/product_name "Jiaolong Series GM5ZG0O". Its keyboard has a button for toggling trackpad on/off. However this key emits keycode 93 which is not mapped to anything in /usr/share/X11/xkb/keycodes/evdev which is the auto-configuration Xorg chooses. I don't want to modify this file because I'm going to lose these changes when xkeyboard-config gets updated by the package manager. However I would like my changes to be permanent and system-wide. Ideally i'd like to have additional local configuration, something like this: /etc/X11/xkb/keycodes/touchpadtoggle
default xkb_keycodes "touchpadtoggle" {
     = 93;
};
/etc/X11/xorg.conf.d/touchpadtoggle.conf
Section "InputClass"
    Identifier "Touchpad Toggle Key"
    MatchIsKeyboard "on"
    MatchProduct "AT Translated"
    Option "XkbKeycodes" "+touchpadtoggle"
EndSection
This doesn't work, probably for multiple reasons: - Xorg does not seem to look in /etc/X11/xkb for configurations - The "+touchpadtoggle" syntax is probably invalid Is this at all possible? Or is there another way to add a single key to the keymap without creating my own layout from scratch?
SnakE (151 rep)
Oct 8, 2022, 11:41 PM
1 votes
0 answers
244 views
How to keep keyboard mapping after reboot?
In order to remap my keyboard I use the following commands: ``` $ setxkbmap -layout fr -variant latin9 -option '' $ setxkbmap -option ctrl:nocaps $ printf "keycode 127 = Caps_Lock NoSymbol Caps_Lock" > ~/.Xmodmap $ xmodmap ~/.Xmodmap ``` After that, everything works as expected. However, when I rebo...
In order to remap my keyboard I use the following commands:
$ setxkbmap -layout fr -variant latin9 -option ''
$ setxkbmap -option ctrl:nocaps
$ printf "keycode  127 = Caps_Lock NoSymbol Caps_Lock" > ~/.Xmodmap
$ xmodmap ~/.Xmodmap
After that, everything works as expected. However, when I reboot (I noticed the same behavior on two of my computers, one is on Lubuntu 20.04 and the other on Ubuntu 20.04), I have swapcaps instead of nocaps and keycode 127 has its original mapping. How can I prevent reboot from changing my remapping?
crocefisso (193 rep)
Sep 24, 2022, 08:31 AM
2 votes
1 answers
349 views
How to remap Caps Lock to a specific key?
By default I have the following key mapping: ``` $ xmodmap -pke ... keycode 49 = oe OE oe OE leftdoublequotemark rightdoublequotemark leftdoublequotemark ... keycode 66 = Caps_Lock NoSymbol Caps_Lock ... ``` I assigned Ctlr to keycode 66 by doing `$ setxkbmap -option "ctrl:nocaps"` Now I'd like to a...
By default I have the following key mapping:
$ xmodmap -pke
...
keycode  49 = oe OE oe OE leftdoublequotemark rightdoublequotemark leftdoublequotemark
...
keycode  66 = Caps_Lock NoSymbol Caps_Lock
...
I assigned Ctlr to keycode 66 by doing $ setxkbmap -option "ctrl:nocaps" Now I'd like to assign Caps Lock to keycode 49. I did:
$ printf "keycode  49 = Caps_Lock NoSymbol Caps_Lock" > ~/.Xmodmap
$ xmodmap ~/.Xmodmap
The result was that pressing keycode 49 activates Caps Lock but pressing it again doesn't deactivate Caps Lock... How could I toggle Caps Lock by pressing keycode 49?
crocefisso (193 rep)
Sep 17, 2022, 10:23 AM • Last activity: Sep 20, 2022, 09:28 AM
Showing page 1 of 20 total questions