You are not logged in.

#1 2017-01-03 03:03:30

xsnake
Member
Registered: 2015-11-27
Posts: 11

[SOLVED] Nautilus "Open in Terminal" F12 accelerator

Hello,

Back in the days, there used to be a shortcut (F12) to open an instance gnome-terminal in the current directory, in addition to the item "Open in Terminal"  in the context menu.

The context menu item is provided by an extension (/usr/lib/nautilus/extensions-3.0/libterminal-nautilus.so) which is included with the gnome-terminal package.

I have found this python script to be used with python2-nautilus, which binds the Backspace key to the "Back" function in Nautilus.

From what I understand, to achieve what I want to do, it would be a matter of modifying the python script to adjust it with the proper action (something like nautilusOpenInTerminal?) and the right shortcut (F12).

Any help to find the proper way to call the "Open in Terminal" action would be appreciated.

Thanks!

Last edited by xsnake (2018-01-06 20:14:05)

Offline

#2 2017-04-27 00:37:21

xsnake
Member
Registered: 2015-11-27
Posts: 11

Re: [SOLVED] Nautilus "Open in Terminal" F12 accelerator

Anyone has an idea?

Offline

#3 2018-01-06 20:13:01

xsnake
Member
Registered: 2015-11-27
Posts: 11

Re: [SOLVED] Nautilus "Open in Terminal" F12 accelerator

Hi again,

I found a neat way to achieve what I referenced in my original post.

First, install package nautilus-terminal from the community repo. This package provides an integrated terminal for Nautilus. Its visibility may be toggled with F4. I do not need this, but editing the script is easier than starting from scratch.

Then, navigate to /usr/share/nautilus-python/extensions and edit file nautilus_terminal.py.

Scroll towards the end of the file and locate "class NautilusTerminalProvider". Add the following line to "def get_widget":

window.addr = url2pathname(uri[7:])

Lastly, add the following lines to "def _toggle_visible":

if event.keyval == 65481: #F12
os.system("gnome-terminal --working-directory=\""+window.addr+"\"")
return True #Stop the event propagation

Save the file, restart Nautilus (nautilus -q), and there you go!

Offline

#4 2019-03-16 21:08:36

xsnake
Member
Registered: 2015-11-27
Posts: 11

Re: [SOLVED] Nautilus "Open in Terminal" F12 accelerator

Update:

After updating package nautilus-terminal, my previous fix does not work anymore. Here is the new method.

Navigate to /usr/lib/python3.7/site-packages/nautilus_terminal and edit files nautilus_terminal.py.

Add the following lines to "def _build_actions" in "class NautilusTerminal":

pop_action = Gio.SimpleAction(name="pop")
pop_action.connect("activate", self._on_ntermwin_pop_action_activated)
self._ntermwin_action_group.add_action(pop_action)

Add the following lines to "def _build_accels" again in "class NautilusTerminal":

self._nautilus_app.set_accels_for_action("ntermwin.pop", ["F12"])

Add a new "def _on_ntermwin_pop_action_activated" inside "class NautilusTerminal":

def _on_ntermwin_pop_action_activated(self, action, parameter):
logger.log("ntermwin.pop action activated")
self._inject_command(" gnome-terminal --working-directory=%s" % helpers.escape_path_for_shell(self._cwd))

Save the file, restart Nautilus (nautilus -q).

Offline

Board footer

Powered by FluxBB