ZedTuX
ZedTuX

Reputation: 3027

Have my GTK application started on startup on Linux

I have an C++ executable that include some GTK code. I want this application to be started on startup of my machine (as root).

I tried with a init script (that is working perfectly when I use it from my user session), but having a look at the log file of my application I see that the latest logged line is before to call Gtk::Application::create() so it seems that it too earlier to initialize GTK.

How can I have my application started after the user session opened so that GTK initialisation is not failing ?

Upvotes: 1

Views: 1539

Answers (1)

LiuLang
LiuLang

Reputation: 773

Create a .desktop file of your application, and put it to /etc/xdg/autostart/ for each user, or to $HOME/.config/autostart/ for current user.

If you want to load that application as root for general users, you may choose to use gksu or other tools to authorize priviledge.

Alternatively, you can see how network-manager is designed. It inits network-manager module as a init-script when system starts, and loads nm-applet, which is GUI for ordinary user, when a user session loads. Thus, network-manager can be managed on all the desktop environment (like Gnome, KDEE, xfce...) by desktop users.

Upvotes: 3

Related Questions