You are not logged in.

#1 2012-12-21 00:17:20

PaulE
Member
From: Dublin
Registered: 2012-12-20
Posts: 27

[SOLVED] cannot set keyboard for X clients

Hi everyone,

I just set up Arch on my Samsung NC20 a few days ago after a couple of years on Ubuntu. I'm enjoying it so far, but I've run into the following problem. I've tried to set my keyboard to 'uk' but I only get a UK keyboard at login time. As soon as I launch an X client, I am back with a US keyboard. (In case it matters, I've mainly been using wmii, LilyTerm, and Firefox. I have no desktop.)

My /etc/vconsole.conf file reads

KEYMAP=uk

and I set up a file /etc/X11/xorg.conf.d/99-keyboard-locale.conf that reads as follows:

Section "InputClass"
    Identifier                  "Keyboard Defaults"
    MatchIsKeyboard    "yes"
    Option                "XkbLayout"    "uk"
EndSection

The option 'uk' is indeed present on my machine (although I tried 'gb' too, to no avail). When I look in /usr/share/kbd/keymaps/i386/qwerty I find uk.map.gz; and I get a UK keyboard when I log in, as I said.

One weird thing is that if I run

setxkbmap -layout uk

from the command line in LilyTerm, I get the following:

No protocol specified
Cannot open display ":0"

I don't know if that's relevant.

Can anyone help? How can I set my keyboard to 'uk' for X clients?

Best,
PaulE

Last edited by PaulE (2012-12-21 22:16:05)

Offline

#2 2012-12-21 15:50:00

ximun
Member
From: Montreal, QC
Registered: 2012-08-14
Posts: 26

Re: [SOLVED] cannot set keyboard for X clients

As far as I know, there is no uk layout for xorg and keymap ≠ X keyboard layout. Always check /usr/share/X11/xkb/rules/xorg.lst.

cat /usr/share/X11/xkb/rules/xorg.lst | grep UK
gb              English (UK) # keyboard layout (following lines are variants)
extd            gb: English (UK, extended WinKeys)
intl            gb: English (UK, international with dead keys)
dvorak          gb: English (UK, Dvorak)
dvorakukp       gb: English (UK, Dvorak with UK punctuation)
mac             gb: English (UK, Macintosh)
mac_intl        gb: English (UK, Macintosh international)
colemak         gb: English (UK, Colemak)

Try adding setxkbmap -layout gb to your .xinitrc file and see if it solves the problem.

EDIT: Added a comment to the first line of output.

Last edited by ximun (2012-12-21 15:55:21)


"The problem is, after a week of intense googling, we’ve started to burn out on knowing the answer to everything. God must feel that way all the time. I think people in the year 2020 are going to be nostalgic for the sensation of feeling clueless." Douglas Coupland - jPod

Offline

#3 2012-12-21 16:34:10

vorbote
Member
From: 8375 ft closer to the stars
Registered: 2011-02-07
Posts: 38
Website

Re: [SOLVED] cannot set keyboard for X clients

Edit /etc/X11/xorg.conf.d/00-keyboard.conf to fit your needs, ideally you are using the evdev driver. Mine reads

# Read and parsed by systemd-localed. It's probably wise not to edit this file
# manually too freely.
Section "InputClass"
        Identifier "system-keyboard"
        MatchIsKeyboard "on"
        Option "XkbLayout" "latam,us"
        Option "XkbVariant" ","
EndSection

(Hmm. Not sure what package created that file, but the answer is valid nonetheless).

Last edited by vorbote (2012-12-21 16:36:33)


I break things and put them back together for fun and sometimes profit, because it is the only way to learn.

Offline

#4 2012-12-21 17:03:27

PaulE
Member
From: Dublin
Registered: 2012-12-20
Posts: 27

Re: [SOLVED] cannot set keyboard for X clients

Thank-you, ximun and vorbote! I already had an xorg.conf.d file set up as vorbote advised, but ximun was evidently perfectly correct in saying that I needed 'gb' and not 'uk'. I've added

setxkbmap -layout gb

to my .xinitrc file and it works perfectly now.

Thanks again. I guess this can be marked as SOLVED.

PaulE

Offline

#5 2012-12-21 17:11:12

ximun
Member
From: Montreal, QC
Registered: 2012-08-14
Posts: 26

Re: [SOLVED] cannot set keyboard for X clients

Glad it worked. Nonetheless, the xorg.conf.d file should suffice to set the layout, so I don't know what's up with that.

PaulE wrote:

Thanks again. I guess this can be marked as SOLVED.

Indeed, you can edit the OP and prepend the [SOLVED] tag to the thread title.


"The problem is, after a week of intense googling, we’ve started to burn out on knowing the answer to everything. God must feel that way all the time. I think people in the year 2020 are going to be nostalgic for the sensation of feeling clueless." Douglas Coupland - jPod

Offline

#6 2012-12-22 10:40:13

orschiro
Member
Registered: 2009-06-04
Posts: 2,136
Website

Re: [SOLVED] cannot set keyboard for X clients

Glad it worked. Nonetheless, the xorg.conf.d file should suffice to set the layout, so I don't know what's up with that.

I was thinking the same. But also here on my Gnome 3 system the .conf alone is not sufficient. Instead I have to use setxkbmap, too. Thus, it might be DE related.

Offline

#7 2012-12-22 11:29:22

vorbote
Member
From: 8375 ft closer to the stars
Registered: 2011-02-07
Posts: 38
Website

Re: [SOLVED] cannot set keyboard for X clients

orschiro wrote:

Glad it worked. Nonetheless, the xorg.conf.d file should suffice to set the layout, so I don't know what's up with that.

I was thinking the same. But also here on my Gnome 3 system the .conf alone is not sufficient. Instead I have to use setxkbmap, too. Thus, it might be DE related.

No, you don't need setxkbmap. Use the configuration tools provided by the desktop environment. In the case of GNOME3 the right place is the Region and Language control panel. KDE, XFCE and LXDE each have their own tools to accomplish the same thing (and please don't hijack threads, this one was already marked as solved).

Last edited by vorbote (2012-12-22 11:29:51)


I break things and put them back together for fun and sometimes profit, because it is the only way to learn.

Offline

#8 2018-02-26 18:50:08

zdavid0123
Member
Registered: 2018-02-26
Posts: 5

Re: [SOLVED] cannot set keyboard for X clients

I tried including setxkbmap in my .xinitrc, and it never worked until I realized that I must put it BEFORE starting the desktop environment. That is,

 # This ~/.xinitrc works fine (Both lines are executed)
setxkbmap -option caps:swapescape 
exec i3

and

 # This ~/.xinitrc does not work (The second line does not have any effect)
exec i3
setxkbmap -option caps:swapescape

Last edited by zdavid0123 (2018-02-26 18:51:19)

Offline

#9 2018-02-26 19:29:17

Slithery
Administrator
From: Norfolk, UK
Registered: 2013-12-01
Posts: 5,776

Re: [SOLVED] cannot set keyboard for X clients

Please don't necrobump old threads, especially with information that is already in the wiki.

Putting this old thread to sleep...


No, it didn't "fix" anything. It just shifted the brokeness one space to the right. - jasonwryan
Closing -- for deletion; Banning -- for muppetry. - jasonwryan

aur - dotfiles

Offline

Board footer

Powered by FluxBB