6

I'd like to change the keybindings in Nautilus. Specifically, I'd like to make it so Ctrl + Tab and Ctrl + Shift + Tab cycles between tabs instead of Ctrl+ PgUp / PgDn. I can't seem to find anything in dconf, and Nautilus only lists the shortcuts and doesn't let me change them. I tried using the solution here, but (1) the file ~/.config/nautilus/accels does not exist, so I can't figure out the syntax/lines I'm supposed to edit, and (2) making the file and copying their code into it didn't do anything. Any help is appreciated! Thanks!

  • 1
    Whatever is shown in dconf-editor > org/gnome/desktop/wm/keybindings can be edited. An accels map is no longer used so it would be useless.. – doug Jun 01 '18 at 22:42
  • I looked in org/gnome/desktop/wm/keybindings, and it only seems to contain keyboard shortcuts for moving windows, not for Nautilus, specifically. Is there anywhere else in dconf that I might find keybindings for Nautilus? – Jonathan Jun 03 '18 at 03:07
  • Take a look here, seems to the only way for custom accels, https://askubuntu.com/questions/680016/keyboard-shortcut-for-open-terminal-nautilus-3-16/696901#696901 – doug Jun 03 '18 at 18:45

3 Answers3

4

You can, but it's not easy: The standard parameters of Nautilus do not allow you to change these keybindings as there are no configuration parameters for them:

gsettings list-recursively | grep --ignore-case nautilus

So you have 2 possibilities:

  1. Switch to Nemo, which has the capabilities you seek out of the box (and more ...)
  2. Clone the source of Nautilus, edit the source code, change Ctrl+PgUp to Ctrl+Tab and build your own version:

    cd Documents
    git clone https://github.com/GNOME/nautilus
    cd nautilus/src
    grep --recursive --ignore-case tabs *
    nano nautilus-window.c #This is where you need to do more work yourself
    cd ..
    ./configure
    make
    sudo checkinstall
    

That's as far as I want to go, because I took the easy way and deployed Nemo because I abhor the direction the GNOME developers took as they prefer "simplicity", whereas I like my stuff complex and full of features.

Sorry! ¯\_(ツ)_/¯

Fabby
  • 34,259
  • Thanks @Fabby. :) What does the grep --recursive --ignore-case tabs * line do? just because of the word tabs, it makes me think that it might be related to the original particulars. personally, i don't care about that particular shortcut, and accordingly wanna see if that's needed for any other use case, or if should be a different command for different keybindings.

    And thanks for the Nemo suggestion - sounds like the better way to go. :)

    – thisissami Jun 04 '18 at 19:38
  • 1
    It shows you all the source code files containing the word tabs. 0:-) I think it's nautilus-window.c you need, but YMMV. Go Nemo, like I did: nemo has a lot of bells and whistles and is far superior to Nautilus, though very similar in its basic usage. @thisissami You'll feel right at home. – Fabby Jun 04 '18 at 19:40
4

This shows up high when googling, but doesn't mention one of the solutions working in 2020, so here you go...

The accels are modifiable through the python-nautilus (nautilus-python in non-Debian-based distros) interface. We install the package and create a plugin:

sudo apt install python-nautilus
mkdir -p ~/.local/share/nautilus-python/extensions
nano ~/.local/share/nautilus-python/extensions/CtrlTab.py

Then insert the following code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import gi
gi.require_version('Nautilus', '3.0')
from gi.repository import GObject, Nautilus, Gtk

class CtrlTab(GObject.GObject, Nautilus.LocationWidgetProvider):
    def get_widget(self, uri, window):
        app = Gtk.Application.get_default()
        app.set_accels_for_action("win.tab-previous", ["<shift><control>Tab", "<control>Page_Up"])
        app.set_accels_for_action("win.tab-next", ["<control>Tab", "<control>Page_Down"])

Save, exit and make sure nautilus gets shut down with:

nautilus -q
2

Old Bug

This is an old bug appearing in many bug reports. This bug report is from 2009.

FireFox and Windows both support Control+Tab for switching tabs. On many laptops Page Up might be hard to reach or poorly labeled. Even on most desktop keyboards Control+Page Up is impossible to perform with the left hand.

For one-handed shortcuts you can use Alt+1 for the first tab, Alt+2 for the second tab, etc.

Gnome's design is for Control+Tab is used for switching panes within windows. For example from the main pane to the left side pane.


Suggested gsettings hack that doesn't seem to work

A "hack" in this bug report illustrates these two gsettings you can view before changing:

$ gsettings get org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ next-tab
'<Control>Page_Down'
$ gsettings get org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/ prev-tab
'<Control>Page_Up'

Then to change them use:

$ gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/next-tab '<Primary>Tab'
$ gsettings set org.gnome.Terminal.Legacy.Keybindings:/org/gnome/terminal/legacy/keybindings/prev-tab '<Primary><Shift>Tab'

This successfully changes behavior switching between gnome-terminal tabs but has no effect in Nautilus or even YAD.