1

Tried a few different answers from here and other websites, but I can't seem to get my laptop keyboard mapping correctly on Debian at all.

My keyboard is a slightly abnormal layout.

It's qwerty, and UK.

Immediately to the right of my space bar, before Alt Gr, I have the | and \ key. When I press this key, I get < and >(shift) respectively.

Above my enter key, I have ~ and #. Currently when I press this, I get \ and |(shift) respectively.

I'm used to having GBP sign on shift+3, but instead I have #. Same applies for " being on shift+2, instead having @.

Here's the keyboard:

cevos p150sm keyboard

I suspect I'm going to need a slightly manual keymapping for this - or at least a default keymapping with some minor changes. Where do I start?

I've tried the following, with different options, to no avail. I can't get the keys to change... at all, let alone to the wrong/right options.

for i in 'console-data' 'console-setup' 'console-locales' 'keyboard-configuration'; do sudo apt-get install $i; done

for i in 'console-data' 'console-setup' 'keyboard-configuration'; do sudo dpkg-reconfigure $i; done

System info:

$ cat /etc/os-release                     
PRETTY_NAME="Debian GNU/Linux bullseye/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

I'm also using i3wm.

Thanks in advance.

--- EDIT

$ cat /etc/default/keyboard 
# KEYBOARD CONFIGURATION FILE

# Consult the keyboard(5) manual page.

XKBMODEL="pc105"
XKBLAYOUT="gb"
XKBVARIANT=""
XKBOPTIONS="lv3:ralt_switch,compose:rctrl"

BACKSPACE="guess"

-----

$ sudo dpkg-reconfigure keyboard-configuration
Options chosen:
 - Generic 105-key PC (intl.)
 - English (UK)
 - Default
 - No compose key
 - No Ctrl+Alt+Backspace
5
  • 1
    Looks like a standard UK keyboard to me. Seems that it's configured as US. What happens when you run sudo dpkg-reconfigure keyboard-configuration? That should show an interface where you can choose your keyboard layout. What's the content of /etc/default/keyboard? Oct 13 '19 at 19:52
  • Thanks @Gilles, I've added some responses to my OP. After I run the reconfiguration, nothing changes.
    – turbonerd
    Oct 13 '19 at 20:04
  • Did you reboot or at least logout/login after the change?
    – wurtel
    Oct 14 '19 at 9:07
  • Not specifically this time @wurtel, but I have rebooted/logged out a number of times since the first time I ran that configuration change. I'll re-run the configuration tonight then reboot immediately after and update this post.
    – turbonerd
    Oct 14 '19 at 9:17
  • Even after a reboot, nothing at all has changed. I'll raise a bounty now.
    – turbonerd
    Oct 17 '19 at 11:05
4

@rastafile's answer sent me down the right track for finding the solution to this.

https://medium.com/@damko/a-simple-humble-but-comprehensive-guide-to-xkb-for-linux-6f1ad5e13450

The above excellent guide gave me the solution.

setxkbmap -layout gb has, without any additional input, mapped all of my keys correctly - exactly as they appear on the laptop.

1
  • In the light of your simple solution, and the broad title, I answered freshly. Somthing between "Solution is setxkbmap gb, thank you" and a 13min tutorial. I am open for edits/cleanup.
    – user373503
    Oct 17 '19 at 16:54
1

So I wrap up the Q, my own answer and dunc's accepted answer:

setxkbmap - set the keyboard using the X Keyboard Extension

Is the (for once) easy solution. No irony - dunk's link is also not a one-liner to read.

setxkbmap [layout [variant [option]]]

...is the synopsis, nicely arranged. Together with the solution:

setxkbmap -layout gb

...you can see how XKB is built up. If the correct layout does not work, a standard variant might help or some other precompiled XKB file:

extd            gb: English (UK, extended, with Win keys)
intl            gb: English (UK, intl., with dead keys)
dvorak          gb: English (UK, Dvorak)

With udev you hot-plug your USB keyboards; with XKB you get a library of layouts and variants to combine, and more.

setxkbmap is the exact pendant to loadkeys for the linux vc (non-X). Once you have a keymap, you just need to load it. Or rather: you can switch the layout any time, not just once at startup or login. XKB, as I pointed out in my first answer, can turn your physical keyboard with labeled keys and scancodes into something completely different. It is almost a programming language.

Linux kernel (drivers) uses the same idea of translation, but in a simplified way.

In the OQ's situation, the automated configuration (?) did not work, even though XKBLAYOUT="gb" is noted in a file.

Systemd has localectl as "frontend" and to tie console and x server together. See man page!

0
+100

You have an empty XKBVARIANT variable, corresponding to a default xorg option. It both shows well in your Q.

For UK keyboards there might be more than one variant, and this COULD even fix your keys. It depends on how exotic your laptop is. Judging by that extra key I am afraid it is exotic.

But the XKB subsystem (of an X server, and this includes also wayland) is also the remedy. It is one of the things that make life hard in X (through complexity). It is hard to find docs. Systemd has a basic interface with it, because the keyboard layout has to do with LANGUAGE settings. And when you think of Quebec, Moscow or London you see that many users on any platform really need to change the keyboard layout drastically. A London user might want to prefer a US keyboard for scripting, but still add a "pound" or "euro" to that layout.

Which brings me to "tweaking" the layout with xmodmap. Or by dumping your XKB config, tweaking it and reloading it. From the second time on you just load the edited file with a script. I forget the names of XKB tools. Something starting with an X ;)

You will find parts of all this in your distro's help, too.

Your case is a simple one I hope, because you only have to swap some few keys.

And keep in mind that in this case (scancode interpretation), X and linux are separate worlds.

4
  • 1
    OK so if I'm totally honest, your post didn't make a lot of sense to me. It did however send me down the right track. This website: medium.com/@damko/… gave me the command I needed. One single command has fixed my problem: setxkbmap -layout gb. Now all of my keys work, even the ones in unexpected locations. Thank you!
    – turbonerd
    Oct 17 '19 at 14:31
  • I'll award you the bounty, but give the solution fully in a separate answer.
    – turbonerd
    Oct 17 '19 at 14:31
  • @dunc no problem! I can't believe it! Thank you so much for feedback. I think I start to comprehend: 99 times I almost loose my mind, and now nr 100 solves a XKB problem with a cmd I got tired of looking up. Sth with x i said. And you say: it works. I cannot believe. I stop now.
    – user373503
    Oct 17 '19 at 14:52
  • @dunc "your post didn't make a lot of sense" -- but now it does? And what can a post do more than send sbd down a fruitful path? I totally agree that NOW my answer can be rewritten. But did it not help you, all this meta information? Bot OK then, new, simple answer, in my words. As I say, I start to get it.
    – user373503
    Oct 17 '19 at 15:11

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.