2

This question already has an answer here:

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?

marked as duplicate by Gilles, dr01, jimmij, MelBurslan, Anthon Apr 4 '16 at 14:37

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Isn't there a “keyboard settings” GUI where you can configure this? – Gilles Apr 1 '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 3 '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. unix.stackexchange.com/questions/65507/… – Gilles Apr 4 '16 at 11:32
1

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

0

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.

  • Thanks for trying to help. I tried both but no dice. – Neil Girardi Apr 1 '16 at 22:00
  • 1
    I 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 Apr 1 '16 at 23:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.