Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I start up Xephyr inside of X, my keyboard map becomes wonky mostly just for non-printing characters. I can't use arrow keys. According to xev, The down arrow gets mapped to Super_R. The up arrow is Print Screen. PgDown is mapped to "Menu". My keyboard works fine in the original X display (:0), but in the Xephyr subdisplay (:1), nothing else quite works right.

I don't have any funky xmodmap things going on in my main X display that I'm aware of. All I really do is setxkbmap -option ctrl:swapcaps.

share|improve this question
You're not using SSH, right? Or in other words: you're using the exact same keyboard and X server with Xephyr like you use without it? And any better results when using the older Xnest? I don't know how that knowledge will help you, but maybe it does. ;-) – Arjan Nov 14 '09 at 18:17
Yep. no ssh. Same keyboard and server. I'll try Xnest. – qedi Nov 14 '09 at 22:02
Xnest did the same thing, but at least it pointed me to the solution. – qedi Nov 14 '09 at 22:24
up vote 5 down vote accepted

I found Bug 19365 which solved my problem:

Starting Xnest / Xephyr with -kb.

share|improve this answer
And no more need for xmodmap either, I hope? Good find! – Arjan Nov 14 '09 at 22:28
(I think you can accept your own answer after 48 hours? Please come back to do so. Thanks!) – Arjan Nov 14 '09 at 22:29

The -kb option doesn't work in Ubuntu 10.04. Here's what worked for me:

Xephyr -keybd ephyr,,,xkbmodel=evdev -ac -screen 800x600 -br -reset -terminate :1

share|improve this answer
There's no need for all the empty commas, just list keyboard options as needed. In my case it is -keybd ephyr,xkbmodel=evdev,xkblayout='de(nodeadkeys)' – Olaf Dietsche Mar 7 at 7:57

You can also run xkbcomp $DISPLAY :1 in X session in which Xephyr was started. This command will copy keyboard map from current server to your newly created. I use it like this:

Xephyr -screen 800x600 :1 > /dev/null &
sleep 2 && xkbcomp $DISPLAY :1
DISPLAY=":1" ./runcommand
share|improve this answer

It seems you're not using SSH for this, right? Still, the following might get you started; it's what I scribbled down to troubleshoot keyboard issues when using ssh -Y:

You can save the current keyboard mapping (when not running Xephyr) using:

xmodmap -pke > ~/my_xmodmap

Then, in Xephyr, you could try to explicitly load that:

xmodmap ~/my_xmodmap

And using xev you can monitor keyboard events. That probably won't help much by itself, but might help you Googling more helpful articles as that command is sometimes mentioned in such articles.

share|improve this answer
That makes some other keys work, but not all. xev claims, for example that the keypad slash is XF86_Ungrab, not KP_Divide as it is defined in the xmodmap file I've dumped and used. – qedi Nov 14 '09 at 17:25

For me (using german keyboard), it only works the combination of the previous solution pointed by Arjan together with the solution pointed by panzi in Xephyr keyboard layout, that is:

Start Xephyr:

Xephyr -keybd ephyr,,,xkbmodel=evdev,xkblayout=de -ac -reset -screen 800x600 -retro :1 &

Save current keyboard mapping and start an xterm loading the mapping:

xmodmap -pke > /tmp/my_modmap ; xterm -display :1 -ls -e "xmodmap /tmp/my_modmap; bash" &

Xephyr server: xserver-xephyr 2:1.9.5-1

Thanks to the original posters!

share|improve this answer
I found a better solution: see my other answer to this question. – Alberto Apr 21 '11 at 8:18

After more unsuccessful googling, man setxkbmap finally pointed me into an easier solution:

USING WITH xkbcomp

If you have an Xserver and a client shell running on different computers and XKB configuration files on those machines are different you can get problems specifying a keyboard map by model, layout, options names.[...] You can solve this problem by running the xkbcomp on the client side too.[..] For example, the command

setxkbmap us -print | xkbcomp - $DISPLAY

makes both steps run on the same (client) machine and loads a keyboard map into the server.

That is,

  • launch Xephyr:

    Xephyr -ac -reset -screen 800x600 -retro :50 &

    (no need to provide keyboard info)

  • and configure the new xsession:

    setxkbmap de -print | xkbcomp - :50

    (you need to know your keyboard layout)

Note: setxkbmap is your friend, and from version 1.2.0 the useful -query option is available to help you troubleshooting your keyboard (see the corresponding patch log).

share|improve this answer
In this answer I indicate how to launch Xephyr to have it properly configured. – Alberto Apr 21 '11 at 8:17
setxkbmap -model evdev -print | xkbcomp :100 :200    

If you use Xephyr with xpra and you have incorrect keyboard map. If you see strange situation: Down key worked as enter (down arrow as break line), up arrow not working - use that command for set true xkb map.

:100 - Display number with control of xpra

:200 - Display number control of Xephyr

May be that command help, if you use x2go and mate desktop environment (if x2go settings keyboard on client turned off)

share|improve this answer
Please explain what this code does—this isn't very helpful as it stands. – bwDraco Feb 2 '15 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .