38

Can anyone tell me how to enable Emacs keybind on Chrome?

I found some links but they are either not clearly mentioning how to do so or not what I want (I don't want external tools to be run for this purpose).

2
  • Your first link indicates the way. I would guess type gconftool-2 --set /desktop/gnome/interface/gtk_key_theme Emacs or maybe gconftool-2 --type string --set /desktop/gnome/interface/gtk_key_theme Emacs. Apr 24, 2012 at 17:11
  • This does not seem to make any difference, I set the relevant configuration item and even restarted my whole system but Chrome does not recognise any Emacs keybindings for me... Nov 30, 2012 at 15:20

5 Answers 5

42
+50

If you're using gtk3 the settings are in the libgtk-3-common package in /usr/share/themes/Emacs/gtk-3.0/gtk-keys.css and you can enable them with:

gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"

And to switch back:

gsettings set org.gnome.desktop.interface gtk-key-theme "Default"

If you're using gtk2 the settings are in the libgtk2.0-common package in /usr/share/themes/Emacs/gtk-2.0-key/gtkrc and you can enable them with:

gconftool-2 --type=string --set /desktop/gnome/interface/gtk_key_theme Emacs

And if you want to customize the keybindings you can copy the settings into ~/.themes/ with cp -r /usr/share/themes/Emacs ~/.themes/

ps. so does this mean you've managed to win the battle against Unity to steal all your modify keys back for Emacs to use?! :)

9
  • Thx for the answer and i'm sorry to be responding late. Right now I have no need to achieve what I described so I can't test. But seems to be feasible solution so +1
    – IsaacS
    Jan 3, 2013 at 22:46
  • 1
    I managed to turn off key stealing from unity. Basically, in the Keyboard section of System Settings you go to the Shortcuts tab, Window section. Disable "Activate the window menu". In the Launchers section, Key to show the HUD, you should set it to RIGHT ALT (or something else). Problems gone! :)
    – MarkovCh1
    Mar 8, 2013 at 22:20
  • Thank you so much :) Kept doing the gtk2 conf, and it wasn't working...
    – Jérémie
    Apr 14, 2013 at 16:15
  • 1
    It is discussed here (stackoverflow.com/questions/126141/…) how to determine which gtk version is used. Jun 3, 2013 at 22:17
  • 1
    Both methods doesn't work for chromium-browser, which is the only application on Ubuntu 14.04 that I found not obeying configured emacs-keybinding. Any hint? May 13, 2014 at 10:22
11

As of Chrome 59, which switched to gtk3, set gtk-key-theme-name to Emacs in ~/.config/gtk-3.0/settings.ini:

[Settings]
gtk-key-theme-name = Emacs
2
  • Ah, so that's why my Emacs keybindings stopped working in Chrome recently. Thanks!
    – cjs
    Jul 6, 2017 at 9:20
  • This works on a Raspberry Pi running Raspbian. If settings.ini doesn't exist, create it, restart Chromium, and presto, Emacs key bindings. Nov 14, 2019 at 16:12
5

Cinnamon has its own settings:

gsettings set org.cinnamon.desktop.interface gtk-key-theme "Emacs" # use emacs
gsettings set org.cinnamon.desktop.interface gtk-key-theme "Default" # use default
0
3

Emacs keybindings for any gtk application except Google Chrome can be easily enabled, just follow the instruction you found.

Emacs keybinding for Google Chrome however was not working at the time of your question (Dec 2012). This is a bug from upstream https://code.google.com/p/chromium/issues/detail?id=11480. It is working now.

The bug has been solved in 2013. But the version of Chromium shipped with Ubuntu 14.04 still was bugged, you can do a security update which will include a version of chromium (v36) with this bug fixed (but as with any other software, total number of bug does not reduce, that is, new features introducing new bugs to replace fixed ones. For me life is harder since i upgrade, because ideographs stopped displaying in tab names).

It seems the other answer offered to you was not aware that your question is Chromium-specific and Emacs keybindings really did not work in Chromium for many years until 2014.

0
0

It didn't work for me until I turned on the "Emacs input" under "Keyboard and Mouse" in gnome-tweaks (command that brings up a settings GUI). I enabled and disabled the other options; only gnome-tweaks does it on my system.

So far, I've seen four proposed solutions (not counting GTK-2 based solutions, since Chrome has been GTK-3 for a while):

  • gsettings set org.gnome.desktop.interface gtk-key-theme "Emacs"
  • [Settings] gtk-key-theme-name = Emacs in ~/.config/gtk-3.0/settings.ini
  • "Emacs input" in gnome-tweaks
  • Wait for Google to patch something that otherwise should work.

All of these seem to be different systems wrestling control over the keybindings, and one of them (or one not listed above) will win. This isn't a good situation, but be aware that you might need to go through the list.

Also, I quit and restarted Chrome in each experiment (though I didn't reboot my computer or X session). I don't know that this is necessary—I don't know if Chrome detects the keybindings "live" or checks for it at startup—but it made for cleaner experiments.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .