10

I am trying to modify the Gnome Shell preferences (in this case the key bindings) using the terminal. I have tried:

gsettings set org.gnome.Terminal.Legacy.Keybindings switch-to-tab-1 '<Alt>1'

But it is giving me an error:

Schema 'org.gnome.Terminal.Legacy.Keybindings' is relocatable (path must be specified)

So I am stuck in there. How can I specify the path? Also, I see the word "Legacy" in there... Is there a better way to do this?

Note: Using Fedora 24 with all upgrades: GNOME Shell 3.20.3, GNOME Terminal 3.20.2.

don_crissti
  • 79,330
  • 30
  • 216
  • 245
Peque
  • 3,354
  • 4
  • 29
  • 34
  • I dont know if that helps but maybe (depending on what you will use the keys), i used xbindkeys to create a list of key bindings from command line in some special machines. If you just need to bind keys, with gnome or not, from command line, then xbindkeys is your best and easy choice. – Luciano Andress Martini Jul 22 '16 at 19:22

1 Answers1

9

Thanks to @don_crissti's help and the answer they pointed me to.

In order to change Gnome Terminal keybindings a path must be provided for the schema (as it is relocatable). So we need to define both a schema and a path:

GSETTINGS_SCHEMA=org.gnome.Terminal.Legacy.Keybindings
GSETTINGS_PATH=/org/gnome/terminal/legacy/keybindings/
SCHEMA_PATH=$GSETTINGS_SCHEMA:$GSETTINGS_PATH

Then we can easily set our keybindings:

gsettings set $SCHEMA_PATH switch-to-tab-1 '<Primary><Alt>1'
gsettings set $SCHEMA_PATH switch-to-tab-2 '<Primary><Alt>2'
...
gsettings set $SCHEMA_PATH prev-tab '<Primary><Alt>9'

In order to list all the available keybindings (and also to check they are properly set):

gsettings list-recursively | grep Terminal.Legacy.Keybindings
Peque
  • 3,354
  • 4
  • 29
  • 34
  • Can you explain the reasoning behind your `GSETTINGS_PATH` value?! I was under the impression it has to be `/org/gnome/terminal/legacy/profiles` and the UUID of the profile is the defining part. But I was unable to find any sensible documentation. The way you describe it, the path could be derived from the schema in two substitutions, i.e. `GSETTINGS_PATH="/${GSETTINGS_SCHEMA,,}"` and then `GSETTINGS_PATH="${GSETTINGS_PATH//./\/}"`. – 0xC0000022L Jan 13 '22 at 16:37
  • @0xC0000022L Sorry, I no longer remember the reasoning behind this answer (it could even be obsolete). Hope it helped and, if it didn't or if you found a better way, please share your answer! ^^ – Peque Jan 13 '22 at 21:40