Programmatically run at startup on Linux?

Jake Petroules picture Jake Petroules · Jul 29, 2010 · Viewed 8.4k times · Source

How do I programmatically set an executable on Linux to run when the user logs in?

Basically, the equivalent of the HKCU\Software\Microsoft\Windows\CurrentVersion\Run registry key in Windows.

Answer

ternaryOperator picture ternaryOperator · Jul 29, 2010

For gnome on Linux, place a .desktop file referring to your application in ~/config/autostart/, the format is fairly simple:

[Desktop Entry]
Type=Application
Exec=foo
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name=foo

and you will have to set the exec bit for this file (chmod +x)

If you are shipping on Linux, you should create one of these anyway and place it in the menus.

For KDE on Linux you should create a symbolic link to your program's executable in the folder ~/.kde/Autostart/