How to create a .desktop file to launch a python script on linux? How to create a .desktop file to launch a python script on linux? tkinter tkinter

How to create a .desktop file to launch a python script on linux?


Standard versions of sh does not have the source command. Perhaps use /bin/bash instead? So it'd be written something along the lines of this:

Exec=/bin/bash -c 'source /home/username/PycharmProjects/ProBlog/venv/bin/activate && /home/username/PycharmProjects/ProBlog/venv/bin/python /home/username/PycharmProjects/ProBlog/ExeMain.py'

I also suggest three other changes: 1) the && operator so that it won't try to run python code until the activate is finished, 2) replace the ~ tilde with the full path in case the desktop environment doesn't properly expand it, and 3) put in the full path to the venv python so that it doesn't default to the system python. Some of these may not be necessary (depending on the system setup), but it doesn't hurt to be careful.