Search code examples
pythonlinuxpython-3.xstartupboot

Run my Python script at login on linux


I have a Python script, and I want it to be autostarted at every login. It's in a linux system. I followed a guide that explains that is enough to create a .desktop file in ~/.config/autostart/*.desktop and write:

[Desktop Entry]
Name=MyApp
Type=Application
Exec=python3 ~/.myapp/myapp
Terminal=false

I tried several times to reboot but the program doesn't execute, even if it seems to be active in the list of application of startup in my lxde environment.


Solution

  • Often things like the ~ (tilde) aren't evaluated when placed in a config file. Try using the complete path instead (/home/user/… instead of ~/…) and see if this works. If this works, you can try to use $HOME instead ($HOME/…) to make this more portable and abstract.