tags:

views:

162

answers:

2

I have an application that is programmed in C# 3.5 under Windows. This application is also Mono-compatible so it is also used on MacOs and Linux operating system.

There is a "Launch at startup" option in my application. For now, it is greyed when the operating system is not windows as I'm using the registry.

But I'm looking for a way to perform the same operation for the other operating systems. And this should be doable with Mono. I need that at least for MacOs (most recent versions) and Linux systems (mostly Ubuntu if it differs from one distrib to another).

Edit : it is a "user application" with UI...

+4  A: 

Unfortunately, each operating system has a different means of setting this up. On Mac+Unix/Linux, you're pretty much going to want this to be a user level option.

For Mac, you can check the System Startup options (for non-gui apps), or manually add it to Startup Items of the user.

For Linux, you'll run into more issues, since differnet distributions handle this differently. For system startup, you often want to add a startup script to /etc/rc.d/rc.local (non-gui, system startup, but this can vary based on distributions). If it's a user application, for Linux, I'd leave this to the user, and take the option out entirely, since it's usually handled at the user level, and the means varies depending on the desktop environment.

Reed Copsey
freedesktop.org specifies user-specific and system-wide graphical session startup locations for compliant desktop environments. Xfce honors these; Gnome and KDE probably do as well. The user-specific default location is `~/.config/autostart/`; I believe the system-wide one is `/etc/xdg/autostart/`. `.desktop` files in these directories are auto-started by the session manager. That is the best bet on Linux, and supporting it is a reasonable thing.
Michael E
Yes, and it's probably the best option. Some distributions break this standard, unfortunately, but they are thankfully gaining traction and becoming more common.
Reed Copsey
It seems that it's quite complicated to do it by code, so the best idea seems to let the user do it manually.
Julien N
+2  A: 

For linux:

If you want your application to start as a deamon when the system boots, you'll need to look into initscripts, which differ between different distributions.

If you want your application to start when the user logs into his desktop, it depends on the user's desktop environment. For example for kde4 you can put a link to your application into ~/.kde4/Autostart.

sepp2k