16

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?

18

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.

  • I have 3 .profile files, located in /home/pi/, /root/ and /etc/skel/. I suppose you're referring to the one in /home/pi/? As you can see I'm not completely comfortable with linux. .bash_profile doesn't exist. – justanotherhobbyist Nov 6 '13 at 16:08
  • Adding setxkbmap se to /home/pi/.profile fixed it. Thanks, you saved me from alot of headache. – justanotherhobbyist Nov 6 '13 at 16:13
  • 2
    @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 '13 at 16:20
  • 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 '15 at 21:56
  • 1
    @WesternGun that's a very different question. As you point out, the .profile is a user-specific setting. You could probably add it in /etc/profile, but that would affect all users. It would be much better to do it by configuring your login manager. But for that, please ask a new question, explaining what operating system you are using, and what login manager. – terdon May 29 '18 at 15:39

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.