I'm running Ubuntu 15.10. I'm running the following command in the terminal to swap the left Alt and left Control keys: setxkbmap -option ctrl:swap_lalt_lctl
. It works, but as soon as I reboot It's gone and I have to run that command again. I tried adding it to the "Startup Applications." I clicked "Add" in the Startup Applications GUI and in the "command" field I entered setxkbmap -option ctrl:swap_lalt_lctl
. I named it "Swap Alt Ctrl." It doesn't work. What am I doing wrong?

- 56,709
- 26
- 150
- 232

- 131
-
Isn't there a “keyboard settings” GUI where you can configure this? – Gilles 'SO- stop being evil' Apr 01 '16 at 23:04
-
I don't think there is a GUI is for this in the current version of Ubuntu (15.10 as of writing). I think there was in some of the previous versions? I would love to see a list of all of the different options that can setxkbmap can take. The xbk documentation that I looked at has a couple of common examples but seems to merely scratch the surface. I've seen a couple of posts with more examples that are geared towards emacs users. I'd love to be able to make the windows key function as a shift key as well. If anyone knows the option for that please post! – Neil Girardi Apr 03 '16 at 23:03
-
Turns out the options got removed from the GUI a while ago. I don't know if there's an option to make a Windows key act as a third Shift key; if there isn't you'd have to make your own layout, see e.g. http://unix.stackexchange.com/questions/65507/use-setxkbmap-to-swap-the-left-shift-and-left-control – Gilles 'SO- stop being evil' Apr 04 '16 at 11:32
2 Answers
I got it working! Here is what I did... I edited the entry I had added to Startup Applications from
setxkbmap -option ctrl:swap_lalt_lctl
to
/bin/bash -c "sleep 15&&setxkbmap -option ctrl:swap_lalt_lctl"
. This does two things: 1. It makes sure that the command is run by bash. 2. It add a delay to endure that the desktop has finished loading by the time the command is executed.
I got the idea from here: https://askubuntu.com/questions/624868/run-command-at-login-ubuntu-15-04#624890

- 131
It may not be what you are looking for but I remember reading it somewhere on one of the SE subsections that gnome has a tendency to overwrite even when you change the Xorg config file. Hence, the workaround is to insert the command you are using into your .bashrc
or .bash_profile
. This way, every time you start a new session, you will run this command and remap your keyboard.

- 6,966
-
-
1I think your diagnosis is correct, but your proposed solution has no chance of working.
.bashrc
and.bash_profile
are not executed at the right time. – Gilles 'SO- stop being evil' Apr 01 '16 at 23:02