The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 1,842 other followers

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:

  • ~ (tilde)
  • @ (at)
  • # (hash)
  • \ (backslash)
  • | (pipe)
  • " (double-quote)

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 Alt key is called Alt-Gr and has different modifier behaviour:
US key character becomes Alt-Gr plus 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:

dpkg-reconfigure keyboard-configuration

raspi-config

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:

service keyboard-setup restart

–jeroen

Via:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: