shell - How to execute a Nautilus script written in Python inside a gnome-terminal window that stays open? -


lets want execute simple python script nautilus, default file manager of gnome:

#!/usr/bin/python3 print("hello") 

of course aim interact selected files in nautilus, want keep simple.

i save script folder ~/.local/share/nautilus/scripts/ , can execute right click context menu:

nautilus script context menu

how can execute nautilus script inside gnome-terminal , keep terminal opened @ end of script?

i have found can achieve want using 2 script files.

script folder

1) hello.sh open gnome-terminal (and potentially leave open)

the first script file ~/.local/share/nautilus/scripts/hello.sh appear in nautilus script context menu , open gnome-terminal in order execute .hello.py:

#!/bin/bash gnome-terminal -- python3 ~/.local/share/nautilus/scripts/.hello.py 

to force terminal window stay open after execution (to see output or debugging purpose if fails), tweak follow make gnome-terminal execute bash @ end:

#!/bin/bash gnome-terminal -- bash -c "python3 ~/.local/share/nautilus/scripts/.hello.py; bash" 

2) .hello.py execute actual script

then, second script file ~/.local/share/nautilus/scripts/.hello.py executed inside gnome-terminal windows opened hidden nautilus script context menu.

#!/usr/bin/python3 print("hello") 

Comments

Popular posts from this blog

python - Operations inside variables -

Generic Map Parameter java -

arrays - What causes a java.lang.ArrayIndexOutOfBoundsException and how do I prevent it? -