Bash – how to make the bash script look 100% like a GUI app (so user never sees terminal)

bashbash-scriptdialogguikde4

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.

Best Answer

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.