Making KDE dialogue boxes appear from shell scripts

Providing graphical feedback in the form of dialogue boxes when you're writing a shell script isn't really that easy to do yourself. If you're a KDE user, though, and want to write a shell script that gives you feedback in the form of one of these.

FOSSwire KDialog

This could be really useful if you want to set up a script that you want to be able to run graphically, for example, by making a link on your desktop to run it.

So how does this all work? The secret is a program called KDialog. It should be installed with recent KDE versions, but if not, install the package kdialog from your package manager.

Making a simple dialogue box appear is pretty simple. To use the example above, I just needed this command:

$ kdialog --title FOSSwire --msgbox "FOSSwire is awesome"

And that's it. Note the double quotes around the main message - if you have any spaces or special characters in either the title or the main text, you'll need to quote it to prevent the shell choking on the space and thinking it's another argument.

As well as msgbox, there are also other types of dialogue you can experiment with creating. For example, you can use a text box to get textual input from the user, which is returned as the application's output. This means you can use it to gather some information from the user and use that later in the script.

$ kdialog --title FOSSwire --textinputbox "Enter some text"

Enter text dialogue

Also available are options for creating yes/no dialogues, error boxes and much more. To find out exactly which type of alert would best suit you, simply run kdialog without any options to see the list of options.

And have fun GUI-fying your scripts with KDE!

Avatar for peter Peter Upfold -

Peter Upfold is a technology enthusiast from the UK. Peter’s interest in Linux stems back to 2003, when curiosity got the better of him and he began using SUSE 9.0. Now he runs Linux Mint 9 on the desktop, runs a CentOS-based web server from home for his personal website and dabbles in all sorts of technology things across the Windows, Mac and open source worlds.

Home » Articles »

Discussion: Making KDE dialogue boxes appear from shell scripts

  1. Rich (guest)

    # Posted on 22 December 2007 at 10:31 AM

    For gnome users, xenity provides a similar system.

  2. Diego (guest)

    # Posted on 28 December 2007 at 09:40 PM

    Debería haber una variable global que defina el backend del dialog del entorno que se esta usando.

    Asi todos los open o save dialogs serían de los entornos favoritos, aunque los programas sean del opuesto.

    $DIALOG --title FOSSwire --msgbox "FOSSwire is awesome"

    para kde export $DIALOG=kdialog para gnome export $DIALOG=xenity

    Tambien esta xdialog y cdialog y simplemente dialog.

    Todo eso debe ya estar estandarizado.

Home » Articles » Making KDE dialogue boxes appear from shell scripts