Shaping up KDE all the way

I think that by now everyone who touched KDE can pretty much figure out how to customize the appearence and shortcuts. Plenty of settings can be changed via kcontrol. Numerous themes can be downloaded from sites like www.kde-look.org. All of these are pretty trivial.

There is more to customizing KDE though. Much more. KDE has a very modular block-type design. This is great because you can easily use these blocks to build something that you need and that noone has created yet or at least not shared in a way easily locatable. I am talking about kdialog and kdcop.

Love question

kdialog

kdialog is a very simple command line tool, which creates graphical user interfaces (GUI). Say, you have a shell script. It does not have to be shell. It can be Perl, python, ruby or whatever else that you are comfortable with. Now imagine that this script needs some input from the user. You can go several ways from here. You can present a command line way of choosing things (with arguments to your script that is). You can create some text user interface. You can program some GUI in programming language that supports it. Or you can use kdialog. kdialog allows you to use blocks of KDE interface like buttons, message boxes, menus, and whatever else is that you want. Example:

[me@here somedir]$ kdialog --yesno "Do you love me?"

Such a simple command will present user with a standard KDE dialog box, which will have question “Do you love me?” written in it and two buttons marked “Yes” and “No” for the user to answer. As soon as user will press any of these two buttons the kdialog will exit. The return code will indicate which choice user has made.

This is just one simple example of what can be done with kdialog. You can get more options and help on parameters by running kdialog without any arguments. There are also a few tutorials on the web. One of the most popular ones is “Shell Scripting with KDE dialogs“.

kdcop

And yet there is even more to learn. kdcop is a mechanism which allows you to send messages to KDE programs which are already running. Most KDE programs accept a lot of messages and can be pretty much controlled by kdcop. Run kdcop without any arguments. You will see a list of running programs in a tree like manner. You can browse through the tree to see what programs accept which calls and which parameters you have to/can pass. Example: I do run knotes always. I can create new notes from the command line (or from a script, or from an email, or whatever) like this:

[me@here somedir]$ dcop knotes KNotesIface newNote "subject test" "body test"

This command will create a new note with subject “subject test” and the body of the note will contain “body test”. If you want to learn more about kdcop, there are a couple of tips here. I could take it forward from there. I am sure you’ll do so too.

One thought on “Shaping up KDE all the way”

Leave a Comment