1

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.

user2880783
  • 145
  • 6
  • 18
  • It just shows message box with System program problem detected. Do you want to report problem now, and buttons: cancel and report problems... – user2880783 Mar 19 '14 at 14:25
  • Try to do it with "Startup Application" utility in Ubuntu. Find it here: http://askubuntu.com/questions/48321/how-do-i-start-applications-automatically-on-login – Nejat Mar 19 '14 at 15:47
  • 1
    /etc/init.d is for system services (daemons). UI applications run in a user/non-root session, after logging in. How to auto-start UI applications depends on the environment (KDE, Gnome, XFCE, etc. pp). – Frank Osterfeld Mar 19 '14 at 17:22

2 Answers2

3

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.

user3427419
  • 1,769
  • 11
  • 15
1

This solution applies to Ubuntu, for programs startup after login

In the activity menu, search Startup and find Startup Applications Preferences.

enter image description here

If it's not there, install with

sudo apt install gnome-startup-applications

Then add your program

enter image description here

Credit: https://linuxconfig.org/how-to-autostart-applications-on-ubuntu-20-04-focal-fossa-linux

Patrick Wu
  • 98
  • 1
  • 7