4

I created a bash script using kdialog (and it runs on Kubuntu 12.04). The GUI is used for every user interaction (after the first one). However, the script still has to be launched from the terminal and the terminal is still visible even though the user never needs to read terminal output or enter anything into the terminal. Is there a simple way to go to the next step and make my bash script look 100% like a KDE Gui application?

From the initial answers by slm and Ilya Ananyev below, I see that making a .desktop file can accomplish this. That's pretty amazing to me and it is the kind of simple answer I was looking for. (I wanted a task I can complete on my lunch hour and take my bash script the rest of the way toward looking like a real GUI app.) The .desktop file may be the right answer for other readers of this question too.

However, in my specific case, the script is an installer script. So I find myself in a Catch-22. How do I install the .desktop file to launch my installer without the user having to first run another installer for the .desktop file?

Furthermore, in my case, the script is used by end users who are not computer literate. The end users purchase a computer with Linux preinstalled at my recommendation. My goal is to let them install my software without going to the terminal at all. (Most likely they have never seen a command prompt before -- some of them don't even know how to use a mouse yet!)

So, it appears, my solution requires some magical way to get the .desktop file installed so that the user can then click it to launch my installer script.

In summary, my main requirements are:

  1. a way to launch the script without showing the terminal. A .desktop file will accomplish this.
  2. a way to keep the terminal hidden during execution (as I rely entirely on kdialog). A .desktop file will accomplish this with Terminal=false set.
  3. optionally, a secure way for the user to enter their sudo password. I know about the kdialog password entry dialog, but the usage examples I've seen are not secure. kdesudo may be a solution but it reprompts for the password many times, ignoring the usual/default sudo timeout of X minutes. So it isn't working for me atm.
  4. simple enough to implement on my lunch hour. A .desktop file will accomplish this.
  5. utilizes my existing bash script with kdialog. A .desktop file will accomplish this.
  6. doesn't require the user to undertake additional setup steps before they can run my script. It turns out that a KDE user can click a .desktop file which resides at any location. So my users can download the .desktop file into their ~/Downloads folder and launch it from there.
7
  • gksudo & kdesu are GUIs for entering the passwords.
    – slm
    Commented Jun 28, 2013 at 7:21
  • Good reference on the anatomy of a .desktop file: linuxcritic.wordpress.com/2010/04/07/anatomy-of-a-desktop-file
    – slm
    Commented Jun 28, 2013 at 7:25
  • My bash script calls sudo about 50 different times. The way it is written, the user enters their password once at the beginning and the default sudo timeout is sufficient to let my script complete without the user having to enter their password again. But I don't know how to replicate that with kdesudo. It asks for the password again every time. Thanks
    – MountainX
    Commented Jun 28, 2013 at 7:50
  • There are some things to try in this thread: kubuntuforums.net/archive/index.php/t-55014.html, to resolve your issue with kdesudo.
    – slm
    Commented Jun 28, 2013 at 8:04
  • @slm - thanks for the link on tty_tickets & kdesudo. Unfortunately, that solution won't work for my users.
    – MountainX
    Commented Jun 28, 2013 at 16:11

1 Answer 1

6

I hope, that I understood you right: you need just a launcher to the existing script. If so, try to write a small .desktop file for your script and place it in ~/.local/share/applications or /usr/share/applications . Here is an example for it:

[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=Sample Application Name
Comment=A sample application
Exec=application
Icon=application.png
Terminal=false

Further (if you want to write kind of installer) you can create it in installation script.

5
  • Of course, in "Exec" you need to write the whole path to your script. Commented Jun 28, 2013 at 6:50
  • Interesting! I know a little about desktop files but I did not realize they could solve most of my requirements so simply. I'll test this out.
    – MountainX
    Commented Jun 28, 2013 at 7:51
  • I updated my question. How can I get the .desktop file installed (by an end user who is not computer literate)? Desktop files can't be easily manipulated by GUI tools such as file managers. They don't act like normal files. They seem to need their own installer or they need to be installed/moved via the command line.
    – MountainX
    Commented Jun 28, 2013 at 20:02
  • This solution works and accomplished all my goals! I updated my question again. Thanks for the answer!
    – MountainX
    Commented Jun 28, 2013 at 23:12
  • You can also generate a .desktop file by right-clicking and selecting Create New > Link To Application in KDE. This can be edited with any text editor or by right clicking the file and, in the Properties window, selecting the tab called Application which can also be used to edit the file Commented Nov 25, 2018 at 19:55

You must log in to answer this question.

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