1

the program is an executable file that prints messages on the terminal;

I want the terminal to open on auto-start (already done);

and then the file to be automatically executed as soon as the terminal opens (tried and failed);

here is what I tried:

I use the mate desktop environment, so I went into "Startup Applications" on the "Control Center";

then I wrote there the command

./profit 100 1

this command runs the profit executable file which is on the home directory of my user.

oh well, at least it does that when I type it on the terminal, but it is not working on the autostart

btw, the exectuable file is the output from the compilation of a code written in C

vanadium
  • 97,564

1 Answers1

1

To automatically open a terminal application in a terminal window after logging in to your desktop, you will need to set Terminal=true in the launcher.

Unfortunately, the "Startup Applications" dialog in the standard Ubuntu desktop does not allow to set this using the graphical interface. You may have more luck in the Mate desktop. But if also there there is no checkmark to set the program to run in a terminal, then still continue use the dialog to create the startup launcher by filling out the Name, Command and Comments fields. As "Command", specify the full pathname of your script. Tip: If you use the "Browse" button to navigate to your script, the full path will be filled automatically.

enter image description here

When you click "Add", a .desktop launcher will be created in the directory .config/autostart in your home directory. Navigate there (make sure to enable "Show hidden files" because the hidden directory .config is not by default shown), and open the launcher with a text editor. Change the line Terminal=false to Terminal=true, and if no such line is there, add it.

Caveat This will cause the script to automatically run in a terminal. If the script terminates, also the terminal will be closed. Thus, if you want the terminal to remain open so you can see the output, add a command that keeps the terminal open, e.g. read -p "Press enter to continue".

vanadium
  • 97,564