You are not logged in.

#1 2012-05-21 20:42:00

Blackened Justice
Member
Registered: 2012-02-11
Posts: 19

[Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

Hey everyone,

I've read on various places how to switch the Caps-Lock and Escape keys (for use with Vim, mainly), but I'm having quite some trouble accomplishing this. I have created a .Xmodmap file in my home folder, and have placed in there the commands needed to switch the two keys, more specifically, the following (from the Vim tips wiki, I have tried several of them, with the same outcome):

keycode 66 = Caps_Lock
keycode 9 = Escape
remove Lock = Caps_Lock
add Lock = Escape
keycode 9 = Caps_Lock
keycode 66 = Escape

The thing is, if I invoke xmodmap normally in a terminal, everything works fine, but when invoked in some X startup script, it behaves unexpectedly. It basically associates Caps_Lock to Esc and Esc to Caps_Lock, but doesn't remove the Caps_Lock functionality from it. I'm using cdm as my dm and Openbox as my wm, I have tried to invoke xmodmap from /usr/share/cdm/xinitrc, adjusted cdm's configuration and tried my user's .xinitrc and .config/openbox/autostart, with no success in either of them. If I place it in .bashrc, it runs when I start a terminal, and works correctly...

Any help would be appreciated,
Cheers

Last edited by Blackened Justice (2012-05-21 23:22:48)

Offline

#2 2012-05-21 20:50:40

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

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

I don't bother with xmodmap, I just put this is .xinitrc

setxkbmap -option caps:escape

Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#3 2012-05-21 21:01:04

Blackened Justice
Member
Registered: 2012-02-11
Posts: 19

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

Well, that works. I tried it with -option caps:swapescape, and now it's perfect! Thank you very much!

But still, any particular reason why it wasn't working correctly with xmodmap?

Cheers

EDIT: Also, on an unrelated matter: How can I set a non-blinking block cursor on a non-X terminal (Ctrl+Alt+F1, etc.)?

Last edited by Blackened Justice (2012-05-21 21:10:16)

Offline

#4 2012-05-21 21:21:40

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

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

Blackened Justice wrote:

EDIT: Also, on an unrelated matter: How can I set a non-blinking block cursor on a non-X terminal (Ctrl+Alt+F1, etc.)?


Old, but so is the console: http://linuxgazette.net/137/anonymous.html


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#5 2012-05-21 22:15:19

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

$ cat ~/.Xmodmap
remove Lock = Caps_Lock
add Lock = Escape
keysym Caps_Lock = Escape
keysym Escape = Caps_Lock

+

xmodmap ~/.Xmodmap

in .xinitrc seems to work here.

Offline

#6 2012-05-21 22:24:41

Blackened Justice
Member
Registered: 2012-02-11
Posts: 19

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

karol wrote:
$ cat ~/.Xmodmap
remove Lock = Caps_Lock
add Lock = Escape
keysym Caps_Lock = Escape
keysym Escape = Caps_Lock

+

xmodmap ~/.Xmodmap

in .xinitrc seems to work here.

I tried that, too, but it worked as described in the OP. Anyway, I'm happy with setxkbmap wink And thank you again, jasonwryan, that article was helpful wink

Cheers

Offline

#7 2012-05-21 22:36:03

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

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

Cool. Please remember to mark your thread as [Solved].


Arch + dwm   •   Mercurial repos  •   Surfraw

Registered Linux User #482438

Offline

#8 2012-05-21 22:38:21

karol
Archivist
Registered: 2009-05-06
Posts: 25,440

Re: [Solved] Switching Caps-Lock and Escape with xmodmap, doesn't work

I've tried the cursor trick too, but
https://bbs.archlinux.org/viewtopic.php?id=97952

bamdad wrote:

basically, all you have to do is use an escape sequence. but if you insert it only in your .whatevershellrc, the blinking cursor will return after opening a programme, e.g. nano. so you have to follow the instructions on the emacswiki page.

http://www.emacswiki.org/emacs/CursorOnLinuxConsole
(I haven't tried it, I don't use console all that much these days)

Offline

Board footer

Powered by FluxBB