Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a standard way to make a program start when a user logs in?

On Ubuntu, for example, you can place a .desktop file in ~/.config/autostart and the application will launch on startup.

Does this apply to other distros as well?

share|improve this question
add comment

1 Answer

up vote 6 down vote accepted

This is not distro specific so much as Desktop Environment or Window Manager specific. First of all, there is the situation of users logging into a text console or remote tty via ssh. What gets run when those users login is usually controlled by their shells rc files and the system shell profiles.

Then there is the graphical environment case, which is probably what you are mostly after. Those depend very much on the environment. Gnome has a session manager that handles launching things on login. I assume KDE has something similar.

Other window managers have their own mechanisms, usually starting with some kind of hook in their config files. It is also possible to build your own environment with a script that acts as the login shell that gets run after authenticating, then does whatever background work you want, then fires off a window manager or DE.

Basically, there is no one way. You need to know something about your target environment.

share|improve this answer
    
In this case, it would be run in a graphical environment. –  Nathan Osman May 4 '11 at 15:40
1  
@George That's asking how to shift a car into reverse. Automatics you have to slide to R but sometimes there is a button you have to push to unlock the lever to get there. Manuals are every which direction. Some you have to jam the lever down, then over. Some have a little ring you lift, then go into a gear slot. Some have a spring you have to push aside. Some grind gears just for the heck of it it seams. You would need to specify a made, model and year. There are more "graphical environents" for linux than you can shake a stick at. –  Caleb May 4 '11 at 20:04
    
Thanks for the answer - I guess my best bet is to code for the most common scenarios (for example, make sure it works at least in Gnome and KDE). –  Nathan Osman May 4 '11 at 21:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.