This question already has an answer here:

I've been trying to figure out how to start an application after Debian (Wheezy) is done booting up and on an LXDE desktop session. It is a mono C# application. The script I have is simply

mono /home/myapp/myapp.exe

I then added this script to init.d and from there did update-rc.d add myapp. This did not work because it would return

(myapp:4820): Gtk-WARNING **: cannot open display:

As apparently not everything is yet set up to be able to use a GTK application. This is why I'd like to start the application AFTER everything has been set up. I've also tried adding it to crontab (-e) by adding this line:

@reboot /etc/init.d/myapp.sh

I've also added

#! /bin/sh
# Provides: beheertool
# Should-Start: console-screen dbus network-manager
# Required-Start: $all
# Required-Stop: $remote_fs 
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start beheertool

To the original script to perhaps make it launch later (with the Required-start: $all part).

None of these have worked, any help would greatly be appreciated.

EDIT 1: The application is a C# Mono application that uses GTK-sharp. The environment itself boots to a GUI (LXDE) without requiring login. When normally running the application outside of the boot script X seems to be running (when checked with pidof X). Adding /usr/bin/startX to the script changed nothing, however.

marked as duplicate by Christopher, jimmij, cuonglm, Anthon, Michael Homer Jul 2 '15 at 20:47

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    What kind of Mono C# application is it? Please edit your question to tell much more about it... (if possible, give its source code, otherwise explain what it does and what are its dependencies). Do you have an Xorg server running when that C# app is started? – Basile Starynkevitch Jul 2 '15 at 14:13
  • Can you provide use with some more information about this application? When are you expecting it to run - after a user logs in or at system boot? Does the system boot to a console login or does it boot to a graphical login? Does it even boot to a login requiring username and password? Those will help use understand how to reply and what to suggest... – mjturner Jul 2 '15 at 14:29
  • 1
    It looks like your app requires a graphical server and, most probably, it has a graphical window when you start it. Have a look here for more details on auto starting GUI apps. – petry Jul 2 '15 at 14:39
  • I've added to the question describing the situation a little more detailed, is more information required? – HeatPhoenix Jul 2 '15 at 14:43
  • Have you tried on rc.local? – jcbermu Jul 2 '15 at 15:02

Your asking for more information led me to finding out that the program had to be started after LXDE was ready for a desktop session.

And as such I googled and found out that /etc/xdg/lxsession/LXDE/autostart contains a list of applications that will be starting after the desktop session is started.

I added

@mono myapp.exe

And rebooted and it worked! Obviously this will only work on LXDE environments and so I will edit the question accordingly.

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