[Xquartz-dev] xmodmap during in .xinitrc does not stick

Marcus Crestani crestani at informatik.uni-tuebingen.de
Thu Jan 23 12:40:26 PST 2014


On one of my machines, xmodmap runs during XQuartz startup but the
changes it makes do not stick.  In my setup (Mavericks, XQuartz 2.7.5),
I have a simple .xmodmap to switch Mod1 and Mod2:

  clear Mod1
  clear Mod2
  add Mod1 = Meta_L Meta_R
  add Mod2 = Mode_switch
  
I run my .xinitrc with `/bin/sh -x', so system.log shows what .xinitrc
is doing:

  23.01.14 20:49:09,867 org.macosforge.xquartz.startx[89292]: xauth:  file /home/crestani/.serverauth.89293 does not exist
  23.01.14 20:49:11,927 org.macosforge.xquartz.startx[89292]: /opt/X11/bin/xinit: XFree86_VT property unexpectedly has 0 items instead of 1
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + userresources=/home/crestani/.Xdefaults
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + usermodmap=/home/crestani/.xmodmap
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + sysresources=/etc/X11/xinit/.Xresources
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + sysmodmap=/etc/X11/xinit/.Xmodmap
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + '[' -f /etc/X11/xinit/.Xresources ']'
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + '[' -f /etc/X11/xinit/.Xmodmap ']'
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + '[' -f /home/crestani/.Xdefaults ']'
  23.01.14 20:49:12,044 org.macosforge.xquartz.startx[89292]: + xrdb -merge /home/crestani/.Xdefaults
  23.01.14 20:49:12,083 org.macosforge.xquartz.startx[89292]: + '[' -f /home/crestani/.xmodmap ']'
  23.01.14 20:49:12,083 org.macosforge.xquartz.startx[89292]: + xmodmap /home/crestani/.xmodmap
  23.01.14 20:49:12,086 org.macosforge.xquartz.startx[89292]: + xset -b
  23.01.14 20:49:12,088 org.macosforge.xquartz.startx[89292]: + xmodmap
  23.01.14 20:49:12,090 org.macosforge.xquartz.startx[89292]: + exec quartz-wm
  
It runs `xmodmap /home/crestani/.xmodmap', but when app_to_run (xterm)
launches, the changes are no longer there:

  crestani at bender [~] xmodmap
  xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):
  
  shift       Shift_L (0x40),  Shift_R (0x44)
  lock        Caps_Lock (0x41)
  control     Control_L (0x43),  Control_R (0x46)
  mod1        Mode_switch (0x42),  Mode_switch (0x45)
  mod2        Meta_L (0x3f),  Meta_R (0x47)
  mod3
  mod4
  mod5
  
I can run xmodmap manually, then the xmodmap settings are correct and
stick as long as XQuartz is running.
  
  crestani at bender [~] xmodmap /home/crestani/.xmodmap
  crestani at bender [~] xmodmap
  xmodmap:  up to 2 keys per modifier, (keycodes in parentheses):
  
  shift       Shift_L (0x40),  Shift_R (0x44)
  lock        Caps_Lock (0x41)
  control     Control_L (0x43),  Control_R (0x46)
  mod1        Meta_L (0x3f),  Meta_R (0x47)
  mod2        Mode_switch (0x42),  Mode_switch (0x45)
  mod3
  mod4
  mod5
  
For debugging, I log the result of `xmodmap'[1] in .xinitrc immediatly
before it execs quartz-wm (see second to last line in the system.log
excerpt above).  It showed the desired mapping (mod1 is Meta and mod2 is
Mode_switch).

There must be something undoing my xmodmap settings between the time my
machine finishes .xinitrc and the time the first xterm comes up.  I
suspect some race condition, possibly with xkb.  Does anybody have a
guess or a hint what I should observe to identify the problem?

Is the xkb error in org.macosforge.xquartz.log related to my problem?

  [3232113.457] (II) GLX: Initialized Core OpenGL GL provider for screen 0
  [3232113.575] X11.app: DarwinProcessFDAdditionQueue_thread: Sleeping to allow xinitrc to catchup.
  [3232113.596] (EE) Error loading keymap /tmp/server-30.xkm
  [3232113.596] (EE) XKB: Failed to load keymap. Loading default keymap instead.
  [3232115.602] noPseudoramiXExtension=0, pseudoramiXNumScreens=1
  [3232116.578] Calling ListenOnOpenFD() for new fd: 8
  
Is xmodmap still the recommended way to modify keyboard mappings in
XQuartz or should I switch to xkb?  How would I change the xkb
configuration, since as far as I understand XQuartz does not use a
static xkb configuration but instead generates the configuration
dynamically from OS X's keyboard settings?

Thanks for your help!

Footnotes: 
[1]  I needed to redirect xmodmap's output to a file but I was not able
     to find the location to where the output of the commands that are
     called by .xinitrc gets logged.  Does anybody know where the output
     is logged?

-- 
Marcus


More information about the Xquartz-dev mailing list