11

After upgrading and getting the last version of Gnome+Wayland, it kind of mostly broke Autokey (even login with Gnome3 on Xorg). After so much time spent trying to get Command+c to copy instead of Control+c (Iuse a Mac keyboard and frequently switch computers), I am at a point where I am about to get rid of Gnome 3 altogether, just because it does not allow me to redefine Cut Copy and Paste keyboard shortcuts. Those who, like me, spend most of their time working in Terminal will understand.

I think my last chance is simply to edit the source code (Gnome3, Wayland, or wherever this is) and recompile the package, but I searched and searched and was unable to find where the keyboard shortcuts or keybindings were set!

Does anyone here know or have any pointers?

Jeff Schaller
  • 67,283
  • 35
  • 116
  • 255
Alex F
  • 218
  • 2
  • 5

3 Answers3

3

I don't know whether these will work with GNOME wayland (I've tested this with earlier versions, with X11, but I think that it should be independent of the server protocol).

Keybindings in general GTK-3.0 "text-boxes" (gedit, nautilus, firefox)

mkdir -p ~/.themes/macos/gtk-3.0/
cp /usr/share/themes/Emacs/gtk-3.0/gtk-keys.css ~/.themes/macos/gtk-3.0/
$EDITOR ~/.themes/macos/gtk-3.0/gtk-keys.css

In the gtk-keys.css file, edit the bindings as you see fit — they're pretty self-explanatory. The lines that would be of particular interest are:

bind "<ctrl>w" { "cut-clipboard" () };
bind "<ctrl>y" { "paste-clipboard" () };

which you should change to (super is typically the "Command" key):

bind "<super>x" { "cut-clipboard" () };
bind "<super>v" { "paste-clipboard" () };
bind "<super>c" { "copy-clipboard" () };

You may want to delete the remaining bindings.

In order to enable your new macos key theme, use gsettings:

gsettings set org.gnome.desktop.interface gtk-key-theme 'macos'

Keybindings in gnome-terminal

dconf write /org/gnome/terminal/legacy/keybindings/copy  \'"<Super>c"\'
dconf write /org/gnome/terminal/legacy/keybindings/paste \'"<Super>v"\'
aplaice
  • 443
  • This works for terminal. How might we enable such bindings to all apps? – Pouria Almassi Aug 02 '20 at 02:36
  • Unfortunately, didn't seem to work in gnome 40 Wayland. Shlould I do it in gtk-4? – Manish S Jul 02 '21 at 06:28
  • I assume you mean the global bindings in general GTK-3.0 text boxes? Unfortunately, gtk-4 has removed support for key themes. :(

    (See here. (It probably goes without saying, but please don't spam that thread unless you have something constructive to add.))

    At this point editing the source, like suggested in the original question, might be the only solution. :/

    – aplaice Jul 03 '21 at 20:30
0

Not sure if you've already tried this, but setkeycodes might be worth looking into.

Also, here's a potentially relevant superuser question: How to disable / re-map keyboard keys in the kernel?

Maybe you can re-map cmd to ctrl with this?

sebasth
  • 14,872
Patrick
  • 121
0

I'm assuming that you've tried any relevant keyboard settings dialogues; for me, on Linux Mint MATE, I have a special settings window for this.

You may be able to use the dconf-editor to set these; I've needed to do that many times for my hotkeys. For my system, the relevant location on the tree is org->mate->desktop->keybindings. You may be able to set it that way. If not, you could do it the "wrong way" and set it as a hotkey for xdotool to type the "correct" binding.

If all else fails, I'm not sure if this would be sufficient, but you may be able to set those bindings directly in the terminal, under Edit->Preferences.

asinck
  • 1