Ubuntu – How to have two sets of shortcut keys for Compiz grid commands “Put Left” and “Put Right”

compizshortcut-keys

I would like to have two shortcuts each for "Put Left" and "Put Right" for positioning windows in the left and right position.

Specifically, I would like the default keys as well as some custom keys that are more accessible when typing:

i.e.:

  • Put Left: <Control><Alt>KP4 and <Shift><Alt>H
  • Put Right: <Control><Alt>KP6 and <Shift><Alt>L

The CompizConfig dialogue box appears to only allow one shortcut key to be assigned.

How can I have two shortcut keys enabled for a single grid compiz-config setting?

Best Answer

One way to do it is simply map the custom secondary keyboard shortcut to the primary (Compiz) shortcut using xdotool.

  1. xdotool is a small command-line utility which allows automation of keyboard and mouse clicks/movements; install it with sudo apt-get install xdotool
  2. We'll assume here that the default shortcuts for Grid Left/Right are as below: (Ctrl+Super+Left/Right):

    enter image description here

  3. Open Settings...Keyboard, and go to the Shortcuts tab. Click + to create a custom shortcut, naming it say Compiz GridRightAlt, and setting the "Command" field to:

    xdotool key --clearmodifiers Ctrl+Super+Right
    

    Click Apply. The right-column will say Disabled, click on it and you'll see "New Accelerator": press your shortcut key combo, e.g. Shift+Alt+L.

    enter image description here

    • Repeat the steps for the left Compiz GridLeftAlt, setting the command to:
    xdotool key --clearmodifiers Ctrl+Super+Left

    and the shortcut keycombo to Shift+Alt+H.

Close the Keyboard settings and that's it!

Related Question