Script to change keyboard layout on Raspberry Pi

To make it easier to change keyboard layout on a raspberry pi I wrote a small shell script. Be warned, this is one of my first scripts. So it is not optimal, and no guarantees. Use at your own risk.

echo "--------------------------------"
echo "Script to change keyboard layout"
echo "--------------------------------"
echo "Which layout should be used? tr=turkish, se=swedish, gb=english etc"
read layout

sudo sed -i 's|XKBLAYOUT=....|XKBLAYOUT="'$layout'"|g' /etc/default/keyboard

echo "Changed to"
grep "XKBLAYOUT" /etc/default/keyboard | sed 's/XKBLAYOUT=\(....\)/\1/g'
sleep 1
sudo reboot
exit 0

Save the code to a file (or downoad from here). Then add execute permission on that file with the command chmod 755 Then you can run the file with ./

Look in this list to find the 2 character code for the country layout you want to use.

One comment

  1. Web Hosting

    The raspi-config tool helps you to configure your Raspberry Pi; several settings can be changed with this tool without having to know the correct commands to use.

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Time limit is exhausted. Please reload CAPTCHA.