Open terminal window and execute Python script on startup
I have a Python script which I would like to execute at every startup. I can run it by adding this to the startup applications:
python3 /path/to/script.py
That works, but it doesn't open a terminal window, so I can't see the program's output. How could I make it open a terminal window and execute the script in there?
Note: I get the window to stay open with input(' ')
at the end of the Python script.
Thanks!
This one should work:
gnome-terminal -e "python3 /path/to/script.py"
To run an application in a system's default terminal we may define a .desktop
file we can then add to our startup applications in ~/.config/autostart
with the following content:
[Desktop Entry]
Encoding=UTF-8
Name=Name of Application
Exec=python3 path/to/application.py
Terminal=true
Type=Application
StartupNotify=true
NoDisplay=true
Note that the terminal will close on termination of our script only if our terminal profile is set to do so (default in gnome-terminal but editable from profile settings).