If I run it manually it works fine, so there is no error there. In order to make it run on startup, I have tried:. None of the above works in Ubuntu I also saw a few ideas about globally changing the keyboard mappings, but most of them were not applicable in Ubuntu Ubuntu no longer uses xmodmapbut instead uses xkb as far as I understand, this facilitates per-window keyboard layouts, among other things.
The maps appears to be loaded hierarchically, with the pc map as the root, and whatever language e. In my particular case, I physically swapped Page Up with Home and Page Down with End on my keyboard, so I very crudely made changes to the system-wide pc map, as follows:.
There are various resources on xkbbut this one is related to Ubuntu. For me, the xkb configuration is too complicated if you want to remap 1 or 2 keys in a way not available in the System Settings. Xmodmap' load using the Startup Applications only works until you suspend, change users or change the keyboard layout. Xmodmap' when needed.
Check the bug report comment 6and download it here. I had this problem in Ubuntu Apparently, Ubuntu is not able to configure the keyboard right away after logging in, but it is a bit later. So if you add a command.
EDIT: This seems to work only after logging in, not after starting up. I'll have to investigate this later. Here is my variant of a key mapping startup script. It converts Caps Lock into Esc on whatever keyboard for use with vivim or gvim. Unlike the answer of q4w56this answer does not use any infinite while; do loop.
Save it as a script.If you are using Linux on MacBook or a key on your keyboard is broken or you have a special key on your keyboard and you want to use it differently than it is designed then you may feel the need to remap the keys of your keyboard.
Remapping the keys means changing the input behaviour of your keyboard and making it work as we want, not as it was intended. If you want to remap the keys in Windows then you can follow this post. The procedure is same for other keys as well. There are two methods for doing this, first method is safe and recommended method but if first method does not work then go for second method which includes modifying the system file and is not preferred.
The steps are as follows:. Step 1: Find the KeyCode number assigned to key and Keysym name of key for your desired keys to swap. Now your keys are swapped but this action is not persistent and only works until you reboot. If you want to make your changes persistent then you need to write a script and make it auto execute at startup or you can make a. I prefer. Second Method: If the above method does not work then you can try this method but please be aware that this method modifies the system file so do not mess with the system file and do it carefully.
Step 1: First we will create a backup of the file in case anything goes wrong so that we can restore it later. Now you have successfully changed your keymap. If you get any unexpected result with this method then restore the backup we created earlier with following command and repeat Step 6 and 7.
If you find it useful and think it will help others as well you can share the article on your favorite social media. How to remap or swap keyboard keys in Windows 7, 8.
How to remap or swap special keyboard keys in Linux?
It only takes a minute to sign up. For Right Super key, xev and showkey give different keycodes -- and respectively. I tried getting keycodes from showkey -kand using xmodmap file below, but that gave a weird map which remapped b key:. There are a lot of players between your keyboard and the process that finally handles the keyboard event. Among the major pieces of the landscape are the fact that the X system has its own keyboard-handling layer, and X associates different "keycodes" with keys than your Linux base system does.
The showkey command is showing you the keycodes in Linux-base-system lingo. For xmodmap you need the X keycodes, which are what xev is displaying. So long as you're planning to work in X and do your key rebinding with xmodmapthen, ignore showkeys and just listen to what xev says. You may have to scroll back a while to find the output you're looking for. Odd, my xev gives a KeyPress and KeyRelease event for alt and for the Windows key, here called "super" :.
There is the 64 and again. Regarding the first question: these days, where the keyboard "driver" in X does not really drive the hardware, it could just pass-through the keycodes from the kernel to the X core, but it doesn't. It adds 8 to the keycode before passing it on. Second: Something in your X session is grabbing the Alt event. The other answers cover this already. The culprit might be related to your window manager. Try a more naked X session. Third: Don't use xmodmap.
It has been outdated for a decade. The new guys are XKB and its tool setxkbmap. Just add it:. The main problem is that you aren't getting the event for the keypress. Looking at the log you posted the reason is apparent. In my case it was xbindkeys, but if you are using a desktop environment they probably have a keybinding system. If you can't determine what program is stealing the key events the best solution is to start another X session without it running.
Run the following command to start another X session on display :1if that is already taken just increase the number at the end. You can of course change the terminal to whatever you prefer or have installed on your system. Then run xev again. That should give you the result without it being captured by other programs. Note that the window manager that gets started is hover-focus, so you will have to place your cursor above the xev window in order for the keys to be captured.
As was said in this excellent answer by dubiousjimthe keycode is different because there are a lot of layers between xev and the kernel. Not sure why it appears that one key generates two scancodes. Note the warning, so you may want to run this in single user mode. And you should be set. Confirm with xev that you're getting a Keypress Event with the keycode of Note that the 'setkeycodes' won't survive a reboot, so you'll have to add it to your init scripts eg.
This is the standard US layout for laptopsbut with the modifier keys swapped round the usual ctrl vs. However, when I output this layout with xkbcomp the resulting keyboard layout seems to be incomplete and has errors too : I.
So - does anybody have clear instructions on how you can reassign the modifier keys in an xkb file? I basically want to take the US layout, and do the following swaps:. In this list, the first label is meant to be the physical key on the laptop going anti-clockwise from capslock towards the arrow keys ; unmodified keys shown in What I'd like to produce is the actual xkb file i.
The reason I want to do this in xkb and not in xmodmap is because xkb can deal with different layouts in different windows, and I've not found a way of doing that with xmodmap, which always seems to be systems wide. I am also confused about Alt vs. Meta - could somebody explain the significance wrt. Or Ubuntu in general? What is it? However, the instructions in the file dont seem to work even regarding the general US keyboard layout included.
So probably something basic is wrong. The answer provided in the Edit. Ubuntu Community Ask! Sign up to join this community. The best answers are voted up and rise to the top. Home Questions Tags Users Unanswered. Reassigning modifier keys with xkb Ask Question. Asked 5 months ago. Active 5 months ago.
Viewed times. In xmodmap this would be: clear control clear lock clear mod1 clear mod2 clear mod3 clear mod4 clear mod5! Active Oldest Votes. Here's why it wasn't clear to me that the maps worked: Adding this map to the GUI doesn't give the same results when switching. Indeed, it seems that the GUI works differently from setxkbmap. So: Does the above map need to be modified somehow?
Or is this a problem with the GUI?How to remap keys in Linux.
Find a Partner. Become a Partner. SUSE Italia. SUSE Luxembourg. SUSE Nederland. SUSE Polska. SUSE Suomi. About Us. Success Stories.
Open Source Contributions. Merchandise Store. Communications Preferences. Advanced Search. Page 1 of 2 1 2 Last Jump to page: Results 1 to 10 of Thread: Xmodmap and setxkbmap.
Join Date May Posts Xmodmap and setxkbmap Hi Forums! I mistakenly posted this on the OpenSUSE forums, so I'll attempt to reproduce the thread flow here: I have bought a new keyboard to help my RSI, it's like an ergonomic keyboard and I need to swap Left arrow cursor with Delete to get normal usage. Running xmodmap queries yields: Code:. Re: Xmodmap and setxkbmap.
Is there an automated method to do it? Or even a straightforward manual process, since I won't need to do this frequently? The idea is to "read" the current keyboard config do not call xmodmapand write your own symbols file based on it. I think you can break options into as many "include" lines as you like. Change the keys you want to modify and prepend them with override :.
Subscribe to RSS
Find the XInput id of your keyboard with xinput list. The map file produced by xkbcomp :0 custom-xkb-keymap consists of many components that you can load by simply swapping the arguments xkbcomp custom-xkb-keymap It shows a few warnings here, but seems to work, when I change the layout in the file. The xkb layout is stored in the symbols directory, e.
The path may vary depending on the system. When you need the layout, you need to cut out the part looking like:. Please make sure, you don't overwrite any file there! Once it is stored there for example as mylayout you can load it by typing setxkbmap mylayout. And this corresponds with the xorg. But this is something I have never done, yet. Instead of using raw dumps that look like decompiled code, you can also make your own symbols file, which is more readable.
I have got my own custom layout, which will probably not be usable for most of you, but you can still take a look at this short file that I use for programming on German keyboards just to get an idea how this can look like and what you can do with a symbols file.
I just solved the problem. After I applied my xmodmap configuration, I used xkbcomp :0 custom-xkb-keymap do copy the current xkb keymap from display :0 to a file named custom-xkb-keymap. There is a similar problem in this thread: Xephyr: keyboard mapping not working properly Similar to the provided solution you can save your keyboard settings with.
This command can take place in the autostart of gnome or other DE's. I don't know if all manual changes will be taken over, but I think it's worth a try. Where to put this file to be automatically loaded without using xkbcomp, I don't know.This article or section needs expansion. Generally, it is only recommended for the simplest tasks.
See X keyboard extension for advanced layout configuration. There are two types of keyboard values in Xorg : keycodes and keysyms. Optionally, install xkeycapswhich is a graphical front-end to xmodmap. Each keycode is followed by the keysym it is mapped to.
The above example indicates that the keycode 57 is mapped to the lowercase nwhile the uppercase N is mapped to keycode 57 plus Shift. Not all keysyms have to be set, but to assign only a latter keysymuse the NoSymbol value.
To have all 8 keysyms available you should configure the intl variant of the keyboard. To permanently make this change, edit the xorg configuration or your.
Using xmodmap to configure individual key mappings
For startxuse:. This article or section is a candidate for merging with Keymap table. Before assignment, the modifier keys need to be cleared. This applies to both modifiers you intend to assign and modifiers on keys that you intend to use. Assigning both left and right to the same modifier means that both keys are treated the same way.
This article or section is a candidate for merging with Mouse buttons. The natural scrolling feature available in OS X Lion mimicking smartphone or tablet scrolling can be replicated with xmodmap.
Xmodmap :. The left, middle and right mouse buttons correspond to buttons 1,2 and 3 respectively in the synaptics driver. Laptop users may prefer having CapsLock as Control. The Left Control key can be used as a Hyper modifier an additional modifier for emacs or openbox or i3. Related articles Xorg Keyboard input Extra keyboard keys in console Xbindkeys.
Reason: Why is xmodmap only recommended for the simplest tasks? Discuss in Talk:Xmodmap. Note: xmodmap settings are reset by setxkbmapwhich not only alters the alphanumeric keys to the values given in the map, but also resets all other keys to the startup default.
If a keyboard is added to a system after a custom table has been applied, the custom table will have to be applied again. Tip: There are predefined descriptive keysyms for multimedia keys, e. Many multimedia programs are designed to work with these keysyms out-of-the-box, without the need to configure any third-party application.
Notes: The point of this section does not seem to be finding anything. The meaning of the modifier keys should be explained in Keymap table where they are mentioned first. See also . Note: xmodmap is case-sensitive. If you get the following error message X Error of failed request: BadValue integer parameter out of range for operationyou will need to adapt accordingly.
Running xmodmap produces a list of modifiers and keys that are assigned to them. Notes: xmodmap is not the only way to do this. Categories : Keyboard configuration Xorg commands. Navigation menu Personal tools Create account Log in. Namespaces Page Discussion. Views Read View source View history. This page was last edited on 3 Marchat