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).

IsaacS
  • 1,106
  • 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. – Chan-Ho Suh Apr 24 '12 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... – John J. Camilleri Nov 30 '12 at 15:20

5 Answers5

42

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?! :)

UTF-8
  • 5,710
  • 10
  • 31
  • 67
aculich
  • 918
  • 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 03 '13 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 08 '13 at 22:20
  • Thank you so much :) Kept doing the gtk2 conf, and it wasn't working... – Jérémie Apr 14 '13 at 16:15
  • 1
    It is discussed here (http://stackoverflow.com/questions/126141/how-do-you-find-out-which-version-of-gtk-is-installed-on-ubuntu) how to determine which gtk version is used. – Marius Hofert Jun 03 '13 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? – Tankman六四 May 13 '14 at 10:22
  • Same as @ZhangWeiwu. Xubuntu 14.04, Chromium 34.0.1847.116 Ubuntu 14.04 aura (260972). XFCE is set up and works great. Can't figure out where the setting for Chromium lives. How does anyone write gmails without it? – drewr Jul 19 '14 at 19:35
  • It's apparently fixed in beta. https://code.google.com/p/chromium/issues/detail?id=319437. No stable package for it yet I guess. – drewr Jul 19 '14 at 19:58
  • I fixed it by just switching to google-chrome-stable. – drewr Jul 20 '14 at 06:16
  • I'm on stock Ubuntu 15.10 and gtk3 fix worked for me, thanks! – Ev Dolzhenko Nov 16 '15 at 13:04
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
xn.
  • 621
  • 5
  • 6
  • Ah, so that's why my Emacs keybindings stopped working in Chrome recently. Thanks! – cjs Jul 06 '17 at 09:20
  • This works on a Raspberry Pi running Raspbian. If settings.ini doesn't exist, create it, restart Chromium, and presto, Emacs key bindings. – Blisterpeanuts Nov 14 '19 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
muru
  • 197,895
  • 55
  • 485
  • 740
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.

Tankman六四
  • 1,681
  • 2
  • 18
  • 23
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.