quinta-feira, 3 de abril de 2008

KDE programming in bash

So you're just about to tell a customer how he can automatically convert a bunch of recently scanned images to a PDF:

"That's easy with cd $TARGETDIR; convert -adjoin *.jpg *.JPG *.jpeg final.pdf"

Err.... why not providing a nice desktop integrated GUI?

KDE provides a way to present the user most of the dialog boxes directly from the shell. It's called kdialog. It is very useful and incredibly simple to use.

For example, one can make a quick JPG -> PDF converter with a couple of lines:

#!/bin/bash

DIRNAME=`kdialog --title "Choose the source directory from JPG files" --getexistingdirectory ~ `
cd "$DIRNAME"
convert -adjoin *.jpg *.JPG *.jpeg final.pdf
kdialog --msgbox "Done"
Other simples examples:
kdialog --error "Error connecting to server0.intranet"


kdialog --combobox "Choose an import filter" ODF OOXML CSV



KDialog provides a flexible interface for presenting KDE Dialog Boxes directly from the shell. Any magic script can interact with end users in a way the matches your desktop. It is used on the AMSN KDE integration.

1 comentário:

S�rgio disse...

The equivalent tool for GTK is zenity. It works in much the same style.