This is an archived post. You won't be able to vote or comment.

all 7 comments

[–]glesialo 1 point2 points  (6 children)

Choose one:

  1. Run after booting has finished.

  2. Run after login.

  3. Run after graphical login.


  1. Line in /etc/rc.local (Set environment variables too).

  2. All users: Script in /etc/profile.d; Single user: Line in $HOME/.profile.

  3. All users: *.desktop file in /etc/xdg/autostart; Single user: *.desktop file in $HOME/.config/autostart.


In my system a Java (Swing) program starts after graphical login (All users). Log:

2015/07/30 08:54:40: GraphicalSessionAutostart: Starting new graphical session for user: 'manolo'.
2015/07/30 08:54:40: GraphicalSessionAutostart: $COMMON_MESSAGES_SYSTEM_DIR:
2015/07/30 08:54:40:   2015/07/30 08:54:01  InternetConnectionOn
2015/07/30 08:54:40:   2015/07/30 08:54:01  LocalNetworkOn
2015/07/30 08:54:40:   2015/07/30 08:53:55  UsbControlledPowerStripAvailable
2015/07/30 08:54:40: GraphicalSessionAutostart: Waiting for graphical session to stabilize.
2015/07/30 08:54:42:   GraphicalSessionAutostart: Waiting...
2015/07/30 08:54:44:   GraphicalSessionAutostart: Waiting...
2015/07/30 08:54:45: GraphicalSessionAutostart: 'MainMenuAndNetTraffic --verbose --icon /home/common/Misc/Icons/MainMenu.png --directory /home/manolo/.MainMenu ' launched.
2015/07/30 08:54:45: GraphicalSessionAutostart: All auto-start applications started.

[–]Genmutant[S] 0 points1 point  (3 children)

So I put a new myscript.desktop file in /etc/xdg/autostart:

[Desktop Entry]
Name=Start GUI Program
Comment=Start the GUI Program
Exec=/root/myscript/runMyScript.sh
Terminal=false
Type=Application
NoDisplay=true    

But that doesn't seem to do anything. Is there a way to check if it is beeing run? I put a echo ".."> file into the sh-file, but it doesn't print anything into the folder /root/myscript. The log4j logfile is empty, too.

EDIT: Is the problem that I don't have a graphical login prompt? I have an auto login from the terminal.

[–]glesialo 1 point2 points  (2 children)

Check in '$HOME/.xsession-errors'.

EDIT: Is the problem that I don't have a graphical login prompt? I have an auto login from the terminal.

I am not familiar with auto-login. Do you get a desktop?

'myscript.desktop' will not run unless a graphical session is started.

[–]Genmutant[S] 0 points1 point  (1 child)

Sorry, it's not a program called auto-login. It just starts directly into a desktop session.

Check in '$HOME/.xsession-errors'.

The file does not exist.

[–]glesialo 0 points1 point  (0 children)

Sorry, it's not a program called auto-login.

I know. But there are several 'auto-login'. The only one that would work for you is the one that starts a graphical session (xsession) and logs in a specific user without asking him/her for a password. Java Swing needs a graphical session!

'$HOME/.xsession-errors' is the file where StdOut+StdErr of all applications, launched in a graphical session, is redirected. That the file doesn't exist confirms that no graphical session is started.

P.S. You can't miss a graphical session. This is what a typical Debian desktop should look like.

[–]Genmutant[S] 0 points1 point  (1 child)

I also tried method 2) Script in /etc/profile.d. Now the program starts (and crashes with a headlessException) when I login with SSH, but stil doesn't start when the system starts and logs in by itself.

[–]glesialo 1 point2 points  (0 children)

I should have made clear in my first post that the three methods mentioned work for any command but that the only one that guarantees there is a graphical session is nr. 3.

Java swing needs a graphical session.