Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.
share|improve this question
    
gksudo & kdesu are GUIs for entering the passwords. –  slm Jun 28 '13 at 7:21
    
Good reference on the anatomy of a .desktop file: linuxcritic.wordpress.com/2010/04/07/anatomy-of-a-desktop-file –  slm Jun 28 '13 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 Jun 28 '13 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 Jun 28 '13 at 8:04
    
@slm - thanks for the link on tty_tickets & kdesudo. Unfortunately, that solution won't work for my users. –  MountainX Jun 28 '13 at 16:11

1 Answer 1

up vote 5 down vote accepted

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.

share|improve this answer
    
Of course, in "Exec" you need to write the whole path to your script. –  Ilya Ananyev Jun 28 '13 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 Jun 28 '13 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 Jun 28 '13 at 20:02
    
This solution works and accomplished all my goals! I updated my question again. Thanks for the answer! –  MountainX Jun 28 '13 at 23:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.