Raspberry Pi brexit – changing your locale away from GB when you’ve a different keyboard
Posted by jpluimers on 2017/10/02
A while ago I wrote about -bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) on fresh Raspbian on Raspberry
I thought my locale issues were solved and they sort of were. Until I had to logon locally and managed to get one or more of these characters in my password:
Then logon would fail locally but work via ssh. Go figure!
Lot’s of people outside the UK using their Raspberry Pi with keyboard and monitor will now say: you’ve the default GB keyboard layout and your keyboard is not GB.
Bingo!
This is how US keys look when using a GB keyboard layout:
US key character becomes plain GB key character ~(tilde)becomes ¬(negation)@(at)becomes "(double-quote)#(hash)becomes £(Pound)\(backslash)becomes #(hash)|(pipe)becomes ~(tilde)"(double-quote)becomes @(at)
This is actually problematic when you have a | (pipe) or \ (backslash) in your password: those characters seem gone!
That’s not completely true: on a GB keyboard:
- there is an extra key having
|(pipe) and\(backslash) on it, - the right
Altkey is calledAlt-Grand has different modifier behaviour:
US key character becomes Alt-Grplus GB key character~(tilde)becomes |(pipe)4(four)becomes €(double-quote)-(minus)becomes \(backslash)
There are more of these modifier combination (not even British and American keyboards lists them all as they are OS specific) so try them out to find them all!
I try to keep all my keyboards US or US-international (with Euro sign), so this little change fixed that for me:
sed -n 's/\(XKBLAYOUT=\)\".*\"/\1\"us\"/p' /etc/default/keyboard
sed -n 's/\(XKBOPTIONS=\)\".*\"/\1\"lv3:ralt_switch\"/p' /etc/default/keyboard
(Note the final statement is only needed because my US-International keyboard has a right Alt-Gr modifier key)
You can also do this in an interactive manner through the console by either of these commands as sudo:
The former will bring you into the “Configuring keyboard-configuration” step of the latter.
Both need to be followed by this command or a reboot:
–jeroen
Via:






Leave a comment