You are not logged in.

#1 2011-02-16 05:34:14

sam113101
Member
Registered: 2010-07-28
Posts: 28

xmodmap and xinitrc

xmodmap ~/.xmodmap won't work if I put it in my .xinitrc file, though will work if I type it manually.

My .xmodmap file:
remove Lock = Caps_Lock
keycode 0x16 = Caps_Lock
keycode 0x42 = BackSpace
add Lock = Caps_Lock

My .xinitrc file:
xmodmap ~/.xmodmap
xset -r 22
xset r 66
exec ck-launch-session startkde

My two xset commands work, but not xmodmap. I don't know what to do.

Last edited by sam113101 (2011-02-16 05:43:10)

Offline

#2 2011-02-16 05:41:51

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: xmodmap and xinitrc

If it is not a typo in your post, the entry should read

xmodmap ~/.xmodmap

as per the Wiki page https://wiki.archlinux.org/index.php/Xmodmap


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2011-02-16 05:46:55

sam113101
Member
Registered: 2010-07-28
Posts: 28

Re: xmodmap and xinitrc

The cursor (on my terminal window) was on the first character so it didn't copy it with the rest of the file. So yeah, that's a typo in my post, the file itself is good. That was nice from you to point it out. Thank you.

Offline

#4 2011-02-16 05:56:26

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: xmodmap and xinitrc

Then you should look at your syntax. I am not sure what you are trying to map, but to clear Caps_Lock I have:

clear Lock

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2011-02-16 06:06:03

sam113101
Member
Registered: 2010-07-28
Posts: 28

Re: xmodmap and xinitrc

It does the same thing.

Offline

#6 2011-02-16 06:14:49

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: xmodmap and xinitrc

Then something else in your syntax is broken...

Just posting "It does the same thing" isn't helping your cause - re-read the wiki page and work through your problem methodically. Just disable Caps_Lock and then, once you have confirmed that works, start trying to map another action to that key (if that is your intent).

No-one here is going to solve the problem for you: we can just point you at ways to attack it - you still have to do the work.


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#7 2011-02-16 06:42:28

sam113101
Member
Registered: 2010-07-28
Posts: 28

Re: xmodmap and xinitrc

If that was the syntax, it would fail manually too, and not just while running it through xinitrc, no?
I'm sorry if I don't seem too cooperative for now, but I've done many google searches, did many attempts, and they all failed.
I'm going to sleep right now because it is getting late, and I will try to modify the syntax a bit tomorrow when I get the time to do it, try the solutions in that thread (if there are more as I wake up). I will keep you up-to-date of what failed and what partially worked.

Offline

#8 2011-02-16 06:55:55

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 30,424
Website

Re: xmodmap and xinitrc

sam113101 wrote:

If that was the syntax, it would fail manually too, and not just while running it through xinitrc, no?

My bad: I missed that it was working manually - sorry.

One way around it might be to try invoking it once X has definitely started:

(sleep 3 && xmodmap ~/.xmodmap ) &

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#9 2011-02-16 07:09:20

Mektub
Member
From: Lisbon /Portugal
Registered: 2008-01-02
Posts: 647

Re: xmodmap and xinitrc

I never achieved that xmodmap worked when started from xinitrc.

It might well be that with a sleep as jasonwryan says that it executes correctly, never tried it.

But it definitely works when executed from the Window Manager startup file (every decent
WM has one). That was my solution.

Mektub


Follow me on twitter: https://twitter.com/johnbina

Offline

#10 2011-02-16 12:24:25

davvil
Member
Registered: 2008-05-06
Posts: 165

Re: xmodmap and xinitrc

Could it be that you are using a DE that is changing the keyboard settings? (KDE, gnome, xfce...)

Offline

#11 2011-02-16 15:39:08

portix
Member
Registered: 2009-01-13
Posts: 757

Re: xmodmap and xinitrc

Changing capslock via xmodmap often does not work properly, i think it does not work if xmodmap is called before the X-server has fully started.
There  are several xkb-options to remap capslock, e.g.

setxkbmap -option caps:backspace

would map capslock to backspace, but there is no option to swap caps and backspace, but one could also create a custom option, but i have never done this.
The other option is the sleep option jasonwryan already suggested.

Offline

#12 2011-02-16 16:08:58

portix
Member
Registered: 2009-01-13
Posts: 757

Re: xmodmap and xinitrc

I tried to create a custom rule and was suckessfull doing the following steps:

  • create the directory ~/.xkb/symbols

  • in ~/.xkb/symbols create a file "mycaps" with the following content:

    partial hidden modifier_keys
    xkb_symbols "swapbackspace" {
        key <CAPS>  {        [       BackSpace  ]       };
        key <BKSP> {        [       Caps_Lock  ]       };
    };
  • In ~/.xkb/ execute

    setxkbmap -print > keymap

    where the content of keymap is

    xkb_keymap {
        xkb_keycodes  { include "evdev+aliases(qwertz)"    };
        xkb_types     { include "complete"    };
        xkb_compat    { include "complete"    };
        xkb_symbols   { include "pc+de(nodeadkeys)+inet(evdev)+compose(menu)+terminate(ctrl_alt_bksp)"    };
        xkb_geometry  { include "pc(pc104)"    };
    };
  • Add the new option to the keymap-file, in my case

        xkb_symbols   { include "pc+de(nodeadkeys)+inet(evdev)+capslock(escape)+compose(menu)+terminate(ctrl_alt_bksp)+mycaps(swapbackspace)"    };
  • In ~/.xinitrc load the new option

    xkbcomp -I$HOME/.xkb $HOME/.xkb/keymap ${DISPLAY}

Offline

Board footer

Powered by FluxBB