4

I'm confused about using setxkbmap. When I use it in my terminal emulator under X, it works:

setxkbmap -layout gr -option # switches layout to greek

However, if I switch to tty2, execute the command (with proper DISPLAY set) and switch back to X, layout does not change:

DISPLAY=:0 setxkbmap -layout gr -option

What am I doing wrong?

  • Setting DISPLAY is not enough. Have you set XAUTHORITY, too? Is this the same user in tty and X? Can you start any X program from tty? – Hauke Laging Oct 23 '17 at 20:47
  • @HaukeLaging - Yes, I tried setting XAUTHORITY, too, confirmed that it was the same in tty and X. Yes, the same user, and all X programs start just fine. setxkbmap also exits without errors (without DISPLAY it complained about unable to open default display). – Rogach Oct 23 '17 at 21:03
  • I suggest you run setxkbmap through strace in tty and an X terminal emulator and compare the outputs. – Hauke Laging Oct 24 '17 at 18:25
  • @HaukeLaging - did that, output is identical (modulo memory addresses) – Rogach Oct 25 '17 at 8:17
0

The X server must be active when you execute that command from a TTY.

export DISPLAY=:0 # Your Display
sleep 1 && setxkbmap us # Change keyboard layout

So I recommend you to execute that command and then, immediately switch to your X display for the changes to be applied.

You can see this behaviour on the xclip -o command. When executed on the TTY, it waits before the X server is active to print out the content of the primary clipboard.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.