Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I'd like to do key remapping that effects only my user, but everywhere within my window manager, not just in a terminal.

In lightdm, I select awesome as my window manager and log in. Are there any hooks for per-user configuration to do before the xserver starts? .xinitrc and .xsession don't seem to be run by lightdm. Even better would be a solution requiring entry point that would do key remappings regardless of window manager, but it seems different window managers have different conventions of how to hook in.

share|improve this question
    
Hi Thomas. This seems a bit of a weird question to me, so please clarify: you are NOT asking for how to remap keys in Awesome. You want to know how to remap keys as soon as you log into lightdm but before the selected session does anything. Is this correct? Why would you want to do this? –  Chan-Ho Suh Apr 15 '12 at 17:28
    
I can't remember exactly what I was trying to do at the time - but remapping keys in Awesome seems like it would fit the bill. I'm guessing I wanted key remaps that would occur before the window manager was started, and work for any window manager, particularly Awesome. –  Thomas Apr 16 '12 at 22:15
add comment

1 Answer

up vote 4 down vote accepted

If you're just interested in remapping keys in a manner that works for any wm, I think I have a way for any typical X wm but you would probably have to configure it per wm. For example, in Awesome, I add the following line to the end of my rc.lua:

awful.util.spawn_with_shell("/usr/bin/setxkbmap -option caps:swapescape -option altwin:ctrl_win")

with my other autostart items. The above options will swap escape and capslock and map the "windows" keys (and the usual ctrl keys) to ctrl.

Whatever DE or wm you use, it should offer a way to autostart commands. Autostarting the appropriate setxkbmap command should remap your keys. I've done this in various window managers. AFAIK, this is the reliable, "proper" way to remap keys, in contrast to xmodmap, which seems flakey.

To remap the keys you want, you need to know the appropriate options and key values to pass. You can find a list in /usr/share/X11/xkb/rules/xorg.lst

Of course, you could use setxkbmap in .xinitrc also, but as you pointed out, lightdm doesn't seem to use it when loading the sessions. Since I use lightdm too, I don't usually think of editing xinitrc, but it just struck me that there should be a way of starting a user-defined X session through lightdm... and I found this answer. That might be more in line with what you want to do.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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