I've got my laptop set up to boot directly into SLiM as the X session manager.

However, the "M" key on my laptop is broken. I've gotten around this when logged in by using xmodmap to remap my extraneous menu key to it.

keycode 135 = m

I put a call to xmodmap in my .xinitrc file as so:

xmodmap ~/.xmodmaprc

This works rather well once I'm logged in. However, my username contains an "m", so I can't type it in directly with the laptop keyboard. Adding a default_user line to my /etc/slim.conf works to allow me to login at least, but if I mistype my password, I have to plug in a USB keyboard or reboot the system entirely to get a second chance.

I found this question here on Stack Exchange, so I copied my .xmodmaprc file to the path it specified (`/etc/X11/Xmodmap). However, that did not work.

How can I get this to work system-wide? My distro is Arch, if that helps any.

  • You need to remap the key at a lower level than xmodmap kicks in. Basically you should find the keyboard map files and change them instead so that when X starts up the keystrokes it gets will already match up with what you want without X having to do modifications. If I have time tomorrow night and this isn't answered by then maybe I'll find the details for you but you might search here for other questions about keyboard remapping, somewhere there are some answers with the details. – Caleb Jun 28 '11 at 22:50
  • 2
    @Caleb It would be enough to tell SLiM to run xmodmap when it starts. But from a glance at the documentation, that doesn't seem to be a supported feature, which is a surprising omission. @MiffTheFox Write an xkb layout or variant to swap M with Menu, and load that from /etc/X11/Xorg.conf. – Gilles Jun 28 '11 at 23:20
  • Try renaming your ~/.xmodmaprc to ~/.Xmodmap and see if there's a difference. I'm using Arch and my file is named .Xmodmap. – user13742 Jan 7 '12 at 22:31

I don't have arch myself, but looking at the package thing online xorg-xinit you should have this file:


Add your xmodmap command in it and it should work: this script is executed by the server when it starts.

Better, it seems it executes all files under /etc/X11/xinit/xinitrc.d/ so just add an executable there which executes xmodmap.

  • Try this approach. Tip: the scripts in /etc/X11/xinit/xinitrc.d/ are named with a number corresponding to what order the scripts are run at startup. The lowest (often most crucial) scripts gets picked first, so make your sure your script is executed after them. – user13742 Jan 7 '12 at 22:18

I once tried to write a generic solution for the case of a broken physical key employing XKB; I saved my configuration changes at https://gitorious.org/xkb-replace-broken. I didn't clean it up. (I.e., unfortunately, I didn't commit the initial unchanged state, so it's not easy to inspect the changes I introduced. I could try to clean it up, and post the resulting revision history when I'm done.) If I remember correctly, it worked.

My idea was (in order to have a fully functional keyboard) to remap the key at the lowest level (keycodes), so that all combinations and layouts use the new physical key that must replace the broken one ("T" in my case).

You can see the new keycodes mapping in the last commit in the "nohack" branch. I forked /usr/share/X11/xkb/keycodes/evdev as /usr/share/X11/xkb/keycodes/evdev-with-broken-t changing the line:

alias <AD05> = <PAUS>;

(In my first revision, which I considered a hack, I simply edited the pristine /usr/share/X11/xkb/keycodes/evdev. That hack is undone in the linked commit. I remember for sure that the "hack" version did work, not quite sure about the "nohack" branch.)

Then I defined a new XKB option ("broken:t" -- see in the above commit), and used it in the configuration file for XKB that is processed in ALTLinux when starting X. (I think you could also put similar options into xorg.conf, with a different syntax, of course; or ask your xinit or the like to run setxkbmap with these options on startup.)


X server isn't fully loaded at the login screen. Everything in XSession.d is loaded after you log in. The only thing running at the login screen is gdm (if your running gnome) and a basic X server. To hook into the X server before you are logged in you need to modify the /etc/gdm/PreSession/Default script.

You can setup xbindkeys to be launched from the PreSession script in the gdm so that you can get X to remap your keys before you login.

  • -1: the question text explicitly mentions SLiM, which is a different login manager than GDM, so GDM recipes do not apply here. – Riccardo Murri Jul 4 '11 at 16:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.