Tuesday, December 5, 2023
 Popular · Latest · Hot · Upcoming
rated 0 times [  1] [ 0]  / answers: 1 / hits: 725  / 2 Years ago, wed, april 13, 2022, 8:49:08

I made a C++ application.

The app just gives me terminal output (just to be sure that my script has launched properly). There is no GUI. I want my app to run when my computer is booted. My script streams video via Ethernet.

I would like to run it at startup. Currently, what I do in terminal is:

cd /home/myproject/build

How can I execute these commands automatically at startup on Ubuntu 18.04?

More From » c++


I assume you're using the default Ubuntu flavor so you have gnome-terminal as your terminal emulator.

To run an executable that outputs to the terminal at startup, you can create a myapp.desktop file in ~/.config/autostart containing the following lines:

[Desktop Entry]
Exec=gnome-terminal -e /home/<username>/myproject/build/myapp
Comment=My awesome video streaming app.

Don't forget to change <username> with the actual value of your UNIX username, which you can get by running whoami in a terminal window.

The most important lines in this .desktop file are the Exec line (the command line of the program to run) and the X-GNOME-Autostart-Enabled line (whether it runs at startup or not). It launches a terminal window (gnome-terminal -e) and runs your compiled app. You can customize the lines beginning with Name and Comment to your liking.

[#1927] Thursday, April 14, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.

Total Points: 290
Total Questions: 115
Total Answers: 114

Location: Egypt
Member since Tue, May 3, 2022
2 Years ago