1
votes

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.

3
At boot or at login time? login of a specific user or of any user? - Alfe
to be more specific, at login time. the login is of a specific or any, doesn't matter. But at the moment I'm trying on a specific user, not root - Sperly1987
Did you try a complete path like /home/allexj/.myapp/myapp? Does this script have x-permissions set? - Alfe
I wrote "chmod +x myapp" in terminal and I also tried as you suggested to write "/home/user/.myapp/myapp" instead of "~/.myapp/myapp" but it doesn't work anyway - Sperly1987
First I was wrong, it worked when I put in the .desktop file "/home/user/.myapp/myapp" instead of "~/.myapp/myapp". Thanks - Sperly1987

3 Answers

0
votes

If you want to run your script on terminal login, place it to /etc/profile.d/

For KDE (at least, KDE 5) you could add applications to autorun in System Settings > Startup and Shutdown > Autostart (either *.desktop files or scripts), it adds links to ~/.config/autostart.

0
votes

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.

0
votes

You can achieve this by adding this line python /home/user/program.py in your .bashrc file. It will be invoked each time when you login to your system.