0

So I have an executable (output of gcc compiling a C program), that I would like to run after login so it is the first thing a user sees upon login. It is a graphical menu that displays system information (read only).

After experimenting around with /.profile, by simply adding the following bash command with the path to the executable:

exec /home/TUI/bin/main

I was able to get my program to run and display the UI after login, but then upon exiting, I am continually prompted to login again in a loop and the process repeats over and over. I believe I am not putting the script in the right location. Would it go in /etc/rc.local? ~/.bashrc ... ?

What would be the best way to go about getting the program to run after a user logs in? (I'm not very experienced with shell scripting and the initialisation process of Ubuntu.)

Eliah Kagan
  • 119,640
Funsaized
  • 123

1 Answers1

3

The problem in your approach is that you use exec.

$ help exec
exec: exec [-cl] [-a name] [command [arguments ...]] [redirection ...]
    Replace the shell with the given command.

    Execute COMMAND, replacing this shell with the specified program.
    ARGUMENTS become the arguments to COMMAND.  If COMMAND is not specified,
    any redirections take effect in the current shell.

[...]

If you omit the exec and simply run your executable as shown below, your login session should not terminate when you close the application.

exec /home/TUI/bin/main 

However, see How do I start applications automatically on login? for alternative (and possibly easier) approaches to autostart applications on login.

Byte Commander
  • 110,243