You are not logged in.

#1 2011-03-15 19:22:54

YAOMTC
Member
Registered: 2010-02-23
Posts: 204

Xmodmap changes won't stay [SOLVED]

It keeps switching back. Here's my .bashrc:

# Check for an interactive session
[ -z "$PS1" ] && return

alias ls='ls --color=auto'
PS1='[\u@\h \W]\$ '

xmodmap ./.xmodmap

Here's .xmodmap:

!
! Swap Caps_Lock and Control_L
!
remove Lock = Caps_Lock
remove Control = Control_L
keysym Control_L = Caps_Lock
keysym Caps_Lock = Control_L
add Lock = Caps_Lock
add Control = Control_L

I'm using KDE. The keys switch back and forth seemingly randomly. Haven't figured out when or why...

EDIT: System Settings > Input Devices > Keyboard > Advanced > Ctrl key position > Swap Ctrl and Caps Lock

I guess KDE didn't care what xmodmap or setxkbmap were doing.

Last edited by YAOMTC (2011-03-19 05:22:17)

Offline

#2 2011-03-15 19:39:59

bohoomil
Member
Registered: 2010-09-04
Posts: 2,376
Website

Re: Xmodmap changes won't stay [SOLVED]

I used to have issues with xmodmap (every now and then it didn't load my config properly), until I started loading it together with X (/etc/X11/xorg.conf.d/20-xkmap.conf). Since then I haven't experienced any problems. Maybe you can give it a shot, too? This is how it looks (of course, you have to use your own mapping):

Section "InputClass"
    Identifier                "xkmap keyboard settings"
    MatchIsKeyboard   "yes"
#MODEL:
    Option                   "XkbModel"      "pc101"
#LAYOUT:
    Option                   "XkbLayout"     "us"
    Option                   "XkbOptions"    "caps:escape, terminate:ctrl_alt_bksp"
#VARIANT:-
#
EndSection

Last edited by bohoomil (2011-03-15 19:41:32)


:: Registered Linux User No. 223384

:: github
:: infinality-bundle+fonts: good looking fonts made easy

Offline

#3 2011-03-15 20:44:34

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: Xmodmap changes won't stay [SOLVED]

Nothing unusual here. Your caps lock and control will switch every time you start a new interactive shell session. xmodmap isn't meant to be invoked by .bashrc. Use a file that's invoked once at X startup like .xinitirc or .xsession (depending on how you start X).

Offline

#4 2011-03-16 03:43:15

YAOMTC
Member
Registered: 2010-02-23
Posts: 204

Re: Xmodmap changes won't stay [SOLVED]

I actually had this problem before I moved the line from .xinitrc to .bashrc. And now that I've moved it back and restarted, it's still happening...

Offline

#5 2011-03-16 09:01:32

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

Re: Xmodmap changes won't stay [SOLVED]

You shouldn't use xmodmap to remap capslock, this sometimes causes problems when xmodmap is executed before the X-server has fully started. You can put

setxkbmap -option ctrl:swapcaps

in your .xinitrc instead.

Offline

#6 2011-03-16 19:43:44

YAOMTC
Member
Registered: 2010-02-23
Posts: 204

Re: Xmodmap changes won't stay [SOLVED]

Hmm... Now they're not switching at all... :S

Offline

#7 2011-03-16 21:15:53

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

Re: Xmodmap changes won't stay [SOLVED]

Have you tried setxkbmap in a running X-session and does it give any errormessages?

Offline

#8 2011-03-16 22:50:42

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Xmodmap changes won't stay [SOLVED]

portix' suggestion worked for me. Pretty neat!

Offline

#9 2011-03-18 21:08:02

YAOMTC
Member
Registered: 2010-02-23
Posts: 204

Re: Xmodmap changes won't stay [SOLVED]

setxkbmap gives no errors, and `setxkbmap -option ctrl:swapcaps' works fine when I run it. But it doesn't seem to have any effect when I put it in .xinitrc.

If it makes any difference, I log in with KDM.

Offline

#10 2011-03-19 05:20:47

YAOMTC
Member
Registered: 2010-02-23
Posts: 204

Re: Xmodmap changes won't stay [SOLVED]

I think I found the solution. If I go to KDE's System Settings, then Input -> Keyboard -> Advanced, I can swap Ctrl with Caps Lock. I guess KDE doesn't play nice with xmodmap/setxkbmap changes?

Offline

#11 2011-05-12 15:50:16

archman-cro
Member
From: Croatia
Registered: 2010-04-04
Posts: 943
Website

Re: Xmodmap changes won't stay [SOLVED]

Anyone knows how to use xmodmap to rebind caps lock to left ctrl? Seems like the parsing changed recently (a new version affected it?) and it stopped working after booting with that version...

edit: nvm, it's ok to use xsetkbmap first xmodmap after it, like this:

xinit: setxkbmap -option ctrl:nocaps
Xmodmap: keysym y = z
keysym z = y

Last edited by archman-cro (2011-05-12 16:06:59)

Offline

Board footer

Powered by FluxBB