Save setxkbmap settings?
35,089
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.
Related videos on Youtube
Author by
justanotherhobbyist
Updated on September 18, 2022Comments
-
justanotherhobbyist over 1 year
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?
-
justanotherhobbyist over 10 yearsI 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 over 10 yearsAdding
setxkbmap se
to/home/pi/.profile
fixed it. Thanks, you saved me from alot of headache. -
terdon over 10 years@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
isroot
's and/home/pi/.profile
is the one for the userpi
. 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 theINVOCATION
section of theman bash
or see here. -
justanotherhobbyist over 10 yearsSo putting it in
/etc/skel/.profile
would be better if I have more than 1 user? Or maybe/root/.profile
? Which is best? -
terdon over 10 years@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. -
justanotherhobbyist over 10 yearsOk, I have no such file in etc, and creating a new .profile didn't fix it.
-
terdon over 10 years@hustlerinc The file in
/etc
should be calledprofile
not.profile
(no.
). Does that work? -
justanotherhobbyist over 10 yearsOh, that's why I didn't find it. Problem solved, thanks!
-
Jan Warchoł over 8 yearsInterestingly, it doesn't work if I put the setting in
~/.bash_profile
- it only works when I add it to~/.profile
(at least on Linux Mint 17.1). -
terdon over 8 years@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 (usingssh
, for example). -
Jan Warchoł over 8 years@terdon but does using
setxkbmap
make sense in a command-line login at all? If I ssh from host A to host B, and I have some xkb settings on host B, they won't matter anyway because my keyboard is controlled by host A. After all, isn't xkb a tool for configuring keyboard in an X environment? -
terdon over 8 years@JanekWarchoł yes, it only makes sense in X which is why it should be in
.profile
and not.bash_profile
. -
Jan Warchoł over 8 years@terdon ok, I have edited the answer to reflect that: unix.stackexchange.com/review/suggested-edits/117339
-
WesternGun almost 6 yearsWhat if I want to use it in login password field? I notice that content in
$HOME/.profile
is not loaded before login. So when I enter password it is still old QWERTY layout. -
terdon almost 6 years@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. -
WesternGun almost 6 yearsOK I have posted another question here.
-
LRDPRDX over 4 yearsDoesn't work in CentOS 7. I try to remap the CAPS to ESC. So I use
setxkbmap -option caps:swapescape
command. I placed it in.profile
but no effect so in.xinitrc
. When I placed it in.bashrc
it only works with terminal. But I need it when I graphically log in. -
terdon over 4 years@LRDPRDX please ask a new question. This will depend on what tool you use to log in, probably.
-
jay.sf almost 3 yearsThat doesn't seem to work (anymore?) on Ubuntu 20.04, I added it to both
/etc/profile
andhome/me/.profile
.