Ubuntu – Window-switching keyboard shortcuts interfere with emacs and cannot be changed in the main keyboard system preferences

emacskeyboardkeyboard-layoutshortcut-keysunity

As of Ubuntu 16.04, Some emacs key combinations involving Ctrl and Alt conflict with the keyboard shortcuts in Ubuntu. One way to fix this is to go to System settings > keyboards > shortcuts and disable / change all the ones that conflict.

A similar question was asked here on Stack Overflow.

However, there are some shortcuts that are not in that setting. For example, in emacs, Alt` (backtick key) is used to open the emacs menu. However, in Ubuntu, it opens up a window switcher with a preview. Similarly, AltTab toggles the switcher. These shortcut keys are not in System settings > keyboards at all.

How can the windows-switching shortcuts be remapped so that they don't interfere with emacs?

Best Answer

Update: much simpler answer courtesy of another thread:

gsettings set org.gnome.desktop.wm.keybindings switch-group "['disabled']"

original answer:

the obvious workaround involves CompizConfig Settings Manager, which can be installed easily as explained in many, many places. However, the steps necessary to remap some keys like Alt-` are completely non-obvious, due to a possible bug in Compiz.

First, in CCSM, go to Ubuntu Unity Plugin. Then go to the last tab, which is labelled Switcher, and examine the Key to flip through windows in the Switcher (without "backwards") item. It is already disabled, but this is actually what is performed by Alt-`. To really disable it, enable this feature (with some garbage random key combination).

Note that if you disable it again, then it really is disabled, but after a reboot the bug will return. Hence, to really get rid of Alt-`, you need to assign it some random garbage key combination, like Shift-Alt-Ctrl-Pause/Break or something.

There are also some other key shortcuts in Compiz, like ones involving Super (Mac/Windows icon key on keyboard) that has this bug in Compiz, e.g. it says disabled but is actually enabled.

Also, in CCSM, there is an Application Switcher category, as well as a "static" version of it. Those should be disabled if Ubuntu Unity Plugin category is enabled, since there are a few conflicting shortcut keys. However, most of the shortcut keys not found in the original Ubuntu System settings -> Keyboard page can be found and modified here.