Reputation: 165
I have gui application made in Qt and I wont to start it when desktop loads. I have tried to do this from terminal like this:
sudo cp MyApp /etc/init.d
sudo chmode 0777 /etc/init.d/MyApp
sudo update-rc.d MyApp defaults
but when I restart computer it gives me program error and asks me if I wont to report it.
Can anyone tell me what could be the problem, and how to solve it? I should point out that I'm new in linux.
EDIT:
I have also tried to create a script that starts this program, and start this script from startup in the same way but it gave me the same error.
I don't know if it's important but when this application start it starts a thread that reads data from serial port.
Upvotes: 2
Views: 9527
Reputation: 140
This solution applies to Ubuntu, for programs startup after login
In the activity menu, search Startup
and find Startup Applications Preferences
.
If it's not there, install with
sudo apt install gnome-startup-applications
Then add your program
Credit: https://linuxconfig.org/how-to-autostart-applications-on-ubuntu-20-04-focal-fossa-linux
Upvotes: 2
Reputation: 1779
You do not start GUI applications in /usr/include/init.d
. Those are system daemons that have nothing to do with GUI. If you want to start an application on start of X session, you have to look at a manpage for Xsession instead.
http://manpages.ubuntu.com/manpages/natty/man5/Xsession.5.html
For example, my ~/.xsession is
xkbset r rate 250 25
startfluxbox
here xkbset
is run under my user, as if I started it. It actually has access to DISPLAY and other X resources, something that system daemons never do. For system-wide, this is in /etc/X11/Xsession.d
or whatever your system uses.
Upvotes: 3