There are times that double-clicking a program is simple and preferred. The idea is to double-click a Python3 .py script on the desktop of Linux and for it to run similar to the cmd program. This technique is going to utilize the MATE desktop environment, therefore the mate terminal program is being run first, it invokes linux bash to then initiate python3, and the .py script we create on the desktop will then run. Here goes.
- create a textfile: python_run_py
- chmod +x python_run_py
From Mate Desktop environment
The contents of python_run_py should be the following code.
mate-terminal -- bash -c "python3 '$1'"
And if you use Gnome desktop environment.
gnome-terminal -- bash -c "<the command or script>; exec bash"
And that’s it, simply tell the desktop to “open with” the python_run_py program and it will run the python3 .py script on a double click.
That’s it for now, and Happy Coding!