How To Execute A Nautilus Script Written In Python Inside A Gnome-terminal Window That Stays Open?
Lets say I want to execute a simple Python script from Nautilus, the default file manager of GNOME: #!/usr/bin/python3 print('Hello') Of course the aim is to interact with selecte
Solution 1:
I have found that I can achieve what I want to do using two script files.
1) Hello.sh
to open gnome-terminal (and potentially leave it open)
The first script file ~/.local/share/nautilus/scripts/Hello.sh
will appear in Nautilus script context menu and will open gnome-terminal in order to execute .Hello.py
:
#!/bin/bash
gnome-terminal -- python3 ~/.local/share/nautilus/scripts/.Hello.py
To force the terminal window to stay open after execution (to see output or for debugging purpose if it fails), tweak it as follow to make gnome-terminal execute bash
at the end:
#!/bin/bash
gnome-terminal -- bash -c "python3 ~/.local/share/nautilus/scripts/.Hello.py; bash"
2) .Hello.py
to execute the actual script
Then, the second script file ~/.local/share/nautilus/scripts/.Hello.py
will be executed inside the gnome-terminal windows opened previously but will be hidden from nautilus script context menu.
#!/usr/bin/python3
print("Hello")
Post a Comment for "How To Execute A Nautilus Script Written In Python Inside A Gnome-terminal Window That Stays Open?"