Ubuntu – Map Caps key to Super+Alt+Ctrl

bashkeyboardshortcut-keys

I think it would be very useful to have my own namespace of shortcut keys where pretty much nothing would ever conflict. For example, I could assign Caps+A to open Ask Ubuntu (or something similarly stupid) and that would really map to Super+Alt+Ctrl+A. I've been trying to understand the custom keyboard settings, but that's one very confusing area of the OS.

Best Answer

Update to remap Caps to Super+Alt+Ctrl:

  1. Open a terminal on type the following commands:

    sudo apt-get install xautomation
    dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:none']"
    
  2. Now create a small bash script that will use xte to create the keypress events. I added a sleep 2 so that you can combine the tree keys with other ones (such as a or more).

    $ cat << EOF > /tmp/caps.sh
    #!/bin/bash
    
    xte 'keydown Control_L' 'keydown Super_L' 'keydown Alt_L'
    sleep 2
    xte 'keyup Control_L' 'keyup Super_L' 'keyup Alt_L'
    EOF
    

    Make it executable and move it to /usr/local/bin:

    chmod +x /tmp/caps.sh
    sudo mv /tmp/caps.sh /usr/local/bin
    
  3. Finally create a custom shortcut from the System Settings menu as usual.

    enter image description here

    Since the Caps key has been disabled by the previous dconf command, you can just type it to define the shortcut accelerator. You'll see 0xff as the key name but it will work.


Previous answer:

You don't need to define Super+Alt+Ctrl as your internal shortcut since after all the key you want to use is Caps.

  1. The first thing to do is to disable the default behaviour of this key, it can be done with the following command. Open a terminal an type:

    dconf write /org/gnome/desktop/input-sources/xkb-options "['caps:none']"
    
  2. Now define a custom keyboard shortcut using the System Settings Menu:

    enter image description here

    The command here can be as you suggested xdg-open http://askubuntu.com

  3. The next step requires to go back to the command line as you can't type Caps to define a new combination accelerator. So list all the defined custom shorcuts with:

    $ dconf list /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/
    custom0/
    custom1/
    

    The one you've just created should be the last one, here custom1. Type the following command to assign Caps+a to open Askubuntu:

    dconf write /org/gnome/settings-daemon/plugins/media-keys/custom-keybindings/custom1/binding '<Caps>a'
    

    Adjust the custom<id> to match yours and the shortcut keys for your needs.

Your new Caps+a is ready to use, needless to log out or restart your system.