1

I am new here been trying to find a way to make a .desktop icon for the sudo command to open the program called GfxTablet but cannot get any info that actually works.

All the plethera of commands I have tried fail to launch tilix terminal and or input a command, I have made lots of .desktop files launching programs them selves but never for a command line to be executed in sudo or none sudo.

All I know is the Exec line has to be precise in what it dictates to perform the operation. If I try to launch the default terminal as in typing the Exec line to state Exec=tilix nothing happens at all, but if I go into say UXterm and type tilix then hit enter it opens, I tried changing the default terminal to one of 3 or 4 terminals on this build of disco dingo 19.04, but none launch from the Exec= line if it includes the folder location followed by the file name when I am writing the .desktop launcher.

I am making it executable and running via right click open with Run Software option and also even dragging the .desktop file into tilix and hitting enter.

The file I want to launch I don't know what file type it is or how to find that file type extension name, as I have done properties via right click which gives no name for file type there, or right clicking choosing the option to look at it's location to see it's path also gives no indication for a file extension.

The path to the file I want to make this .desktop launcher for is as follows:

/home/pc/GfxTablet/driver-input/networktablet

The file name I need to launch is as follows:

networktablet

launching the application which works in all terminals if typed in the command for launchin it is as follows:

sudo ./networktablet

I have been at this 36 hrs plus now trying to figure it out I had been getting some intermittent help online but that failed, it's driving me crazy, I want it to add the icon to the docky dock, as I am making my own customized distribution.

But I would like to transfer it to other machines if necissary at some stage when customized fully, so I need it to be saved when completed as a systemback backup to do that the easy way with everything as is ready to go, I want it on the dock when re-installing or installing to any machine and the ease of accessing it on any machine from the dock by simply clicking a icon for it as aposed to typing it in to launch all the time through a terminal I have to click and open first, the same for if I wish to add further commandlines to open one click instead of open a command shell then type it in, I would like to have them in the app search as well meaning they need to be a .desktop file in the .local/share/applications folder that much I have learned with making other launchers.

Please can someone help I am very new to linux as in days but am good with windows not so much in commandline but anything else, I just switched os's for good I prefer the security and the speed and fluidity of the ubuntu os.

I'm hoping for some help to come, so I can keep my hair as it is before I pull it all out lol

Thanks in advance

1 Answer 1

1

In previous versions of Ubuntu, the answer would have been easy: use gksudo in the "Exec=" line of the launcher. It would, before launching the actual program, provide a graphical dialog to enter the user's password. However, "gksudo" indiscriminately allowed a privileged user to run any graphical program as root, and this is now deprecated. It has been replaced by pkexec, which in addition to asking for a password will first check if you are trying to run a program that explicitly is allowed to be run as root. Additionally, it will by default never allow a graphical program to fully run as root. The possibility, however, is still there to accommodate legacy graphical programs designed to fully run as root.

man pkexec explains how you can proceed to run your custom executable as root.

  1. Create an action file, based on the template you find in man pkexec (see under Example). Provide your own <action id= and change <annotate key="org.freedesktop.policykit.exec.path"> to the full command of your executable. Optionally, you can adopt parameters as the icon, description, vendor information, etc.

  2. Place the file in the directory /usr/share/polkit-1/actions

In the .desktop launcher, precede the full command of your executable with pkexec. If all goes well, clicking the launcher should display a dialog to enter your password, along with the message specified in the file.

If the command provides terminal output you wish to see, then include a line "Terminal=true" in your .desktop file. That way, the command will launch in a terminal that will remain open as long as the command is running.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .