26

I'm having trouble setting my keyboard settings to swedish, running Raspbian on a raspberry pi. I've tried everything and the only thing that worked was the command setxkbmap se.

But this doesn't permanently save the settings, and it's back to default after reboot. Is there a command to permanently save these settings?

1 Answer 1

34

An easy way would be to add the command to your $HOME/.profile file (you can create it if it doesn't exist):

setxkbmap se

That should make it run every time you log in.

Note that you should use $HOME/.profile rather than $HOME/.bash_profile, $HOME/.bashrc or some other similar file. This is because this setting should be read by your login manager.

19
  • 3
    @hustlerinc the /etc/profile is the global one which will always be read, whichever user is logging on. Each user then has their own personal .profile file in their home folders. So, /root/.profile is root's and /home/pi/.profile is the one for the user pi. I asked about the other files because if $HOME/.bash_profile or $HOME/.bash_login exist those files are read instead of $HOME/.profile. If they don't exist, never mind. For more details, read the INVOCATION section of the man bash or see here.
    – terdon
    Nov 6, 2013 at 16:20
  • 1
    So putting it in /etc/skel/.profile would be better if I have more than 1 user? Or maybe /root/.profile? Which is best? Nov 6, 2013 at 16:26
  • 1
    @hustlerinc if you want all users to have that layout, add it to /etc/profile. Adding it to /skel/profile will cause any new user to have the layout set in their personal $HOME/.profile but will not affect existing users.
    – terdon
    Nov 6, 2013 at 16:28
  • 1
    @JanekWarchoł yes, that's because you are logging in graphically and while some login managers source ~/.profile, to my knowledge, none of them source ~/.bash_profile. It will work in ~/.bash_profile if you log in from the command line (using ssh, for example).
    – terdon
    Nov 20, 2015 at 21:56
  • 3
    That doesn't seem to work (anymore?) on Ubuntu 20.04, I added it to both /etc/profile and home/me/.profile.
    – jay.sf
    Jun 1, 2021 at 10:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .