How do I disable mnemonics in GTK3?

In Natty Narwhal I used to do some nifty tricks with .gtkrc-2.0 to disable mnemonics (underlined menus) but now it's impossible. I assume in Oneiric Ocelot it will be something different because it uses GTK3.

I used to achieve this by adding the following lines:

gtk-enable-accels = 0
gtk-enable-mnemonics = 0

How can I get rid of the mnemonics in Oneiric Ocelot?


Solution 1:

To "disable" mnemonics for Nautilus 3.10.1 on Ubuntu 14.04 which uses GTK3:

  1. Create the following path & file if it doesn't already exist.
    /home/YOURUSERNAME/.config/gtk-3.0/settings.ini
  2. Then add:
    [Settings]
    gtk-enable-mnemonics = 0
  3. Then logout and log back in.

Sources:
* https://mail.gnome.org/archives/gtk-list/2011-March/msg00108.html
* https://developer.gnome.org/gtk3/stable/GtkSettings.html

p.s. Note that the GTK docs say you should have an environment variable called XDG_CONFIG_HOME but I didn't have one. I did have an existing ~/.config/gtk-3.0 folder and it appears it is looking there by default, without the environment variable.

Solution 2:

GTK3 doesn't use gtkrc anymore, but moved to styling with CSS. But there still is a way to change global settings. Quoting from the GTK reference:

GTK+ reads default values for settings from settings.ini files in /etc/gtk-3.0 and $XDG_CONFIG_HOME/gtk-3.0.

See that page for some more details.

I wonder if this works in Unity though, with the global menu. I don't know if these settings are adapted by it.

Solution 3:

After so long time and no answer found on my question I found it!

To hide mnemonics (keyboard accelerators) in GTK 3.x you just need to open:

/usr/share/themes/THEME_NAME/gtk-3.0/settings.ini

Add the following line:

gtk-enable-mnemonics = 0

And save the file. Log out or change your theme with another one then change it back. That's all. Nothing hard to do, only little research.

PS: Of course after update of ubuntu-light-themes package this will be lost and need to be redone again.