12

I would like to launch a Gnome application with root privileges at login.

I have tried adding a script to launch using update-rc.d myscript.sh defaults.

It looks like the application does launch, but it is no longer there by the time the gnome gui arrives.

How can I do that?

benlad
  • 255

2 Answers2

12

Running graphical things as root is a bad idea for security but I'm going to assume you know that and that you have exhausted any other methods. You need to do two things:

  1. Allow your user to run the command via sudo without a password by editing /etc/sudoers. You can find a brief explanation here but you're looking for something like this:

    username ALL=(ALL:ALL) NOPASSWD:/path/to/command 
    

    Obviously replace the username and /path/to/command with real values, stick that in there and then try sudo -k /path/to/command (the -k just means it'll ask for your password if it doesn't know any better - it won't ask if your sudoers edit was correct).

  2. Auto-launch your application via the standard "Startup Applications", calling sudo /path/to/command

And that's it.

Oli
  • 299,380
5

You could try to create a custom application launcher (.desktop file) with gksudo <command> as command to run, and add that laucher to the autostart settings (System - Settings - Autostart or Startup). Another way would be to put the .desktop file directly into ~/.config/autostart or (for all users) /etc/xdg/autostart.

tohuwawohu
  • 7,502