

Desktop COmmunication Protocol, DCOP, is a lightweight mechanism for inter-process communication. DCOP allows the user to interact with programs that are currently running. KDE supplies two programs to utilitize DCOP: dcop, a command-line program, and kdcop, a GUI program.
A few notes about using dcop:
dcop [options] [application [object [function [arg1] [arg2] ... ] ] ]
Applications that can open more than one window at a time will be listed as <application>-PID
All the arguments are case-sensitve. setFullScreen and setfullscreen are two different functions.
The regular expression token * can be used in the application and object arguments.
%dcopkonqueror-16006 konsole-8954kon*
Some example commands and their output are below:
%dcopkonsole-8954konsole*
One Konsole is running with a PID of 8954.
%dcopKBookmarkManager-.../share/apps/kfile/bookmarks.xml KBookmarkManager-.../share/apps/konqueror/bookmarks.xml KBookmarkNotifier KDebug MainApplication-Interface konsole (default) konsole-mainwindow#1 ksycoca session-1 session-2 session-3 session-4konsole-8954
Here you see that there are four sessions running.
%dcopQCStringList interfaces() QCStringList functions() int sessionCount() QString currentSession() QString newSession() QString newSession(QString type) QString sessionId(int position) void activateSession(QString sessionId) void nextSession() void prevSession() void moveSessionLeft() void moveSessionRight() bool fullScreen() void setFullScreen(bool on) ASYNC reparseConfiguration()konsole-8954konsole
Here are the options for the main Konsole program.
%dcopQCStringList interfaces() QCStringList functions() bool closeSession() bool sendSignal(int signal) void clearHistory() void renameSession(QString name) QString sessionName() int sessionPID() QString schema() void setSchema(QString schema) QString encoding() void setEncoding(QString encoding) QString keytab() void setKeytab(QString keyboard) QSize size() void setSize(QSize size)konsole-8954session-1
Here are the options for the first session, session-1.
%dcopkonsole-8954konsolesetFullScreentrue
This sets Konsole to full screen.
When there is more than one application/object, which one should you use? Got a reference?
%echoDCOPRef(konsole-7547,konsole)$KONSOLE_DCOP%dcopsession-6$KONSOLE_DCOPnewSession%dcopstartkonsole-9058 #!/bin/sh konsole=$(dcopstart konsole-script) session=$(dcop $konsole konsole currentSession) dcop $konsole $session renameSession Local session=$(dcop $konsole konsole newSession) dcop $konsole $session renameSession Remote session=$(dcop $konsole konsole newSession) dcop $konsole $session renameSession Code dcop $konsole $session sendSession 'cd /my/work/directory'konsole
You can use KDE dialogs from your own scripts, to combine the power of UNIX® shell scripting with the ease of use of KDE.
kdialog --msgbox 'You have new mail!'kdialog --title 'New Mail' --msgbox 'You have new mail!'The KDialog part can be replaced via
--caption option
kdialog --title 'New Mail' --msgbox 'You have new mail!' --dontagain myfile:mykeySaves whether to show again in
$ (by writing
into this file the following lines:KDEHOME/share/config/myfile
[Notification Messages] mykey=false
Instead of --msgbox you can also use
--sorry and --error, as appropriate. For
instance, you might use kdialog --sorry 'The
network can not be reached' or kdialog
--error 'Mail box can not be opened'.
It is also possible to create message boxes that accept a yes or no answer.
kdialog --yesno 'Do you want to connect
to the Internet?' echo $?| Return Value | Meaning |
|---|---|
| 0 | Yes, OK, Continue |
| 1 | No |
| 2 | Cancel |
Make sure to store the result in a variable if you do not use it
directly, the next command will fill $? with a new value You can use
--dontagain here as well, it will remember the users choice
and returns it the next times without showing the dialog any more.
Further variations are:
--warningyesnolike --yesno but with a different
icon
--warningcontinuecancelWith and buttons.
--warningyesnocancelWith , and button. For example:
kdialog --warningyesnocancel 'Do you want
to save the changes?'kdialog --inputbox "Enter your name:" "YourName"The result is printed to stdout, to put it in a variable you can use
name=$(kdialog --inputbox "Enter your name:"
"YourName"). The last argument is optional, it is used to
pre-fill the dialog.
password=$(kdialog --password "Enter your password:")The --dontagain option does not work with
--inputbox or --password
There are two dialogs that let the user make a choice from a list:
--menuLets the user select a single item from a list.
--checklistLets the user select one or more items from a list.
city=$(kdialog --menu "Select a city" a London b Madrid c Paris d Berlin)$city will a, b, c or d.
city=$(kdialog --checklist "Select cities" a London off b Madrid on c Paris on d Berlin off)Madrid and Paris will be pre-selected. The result with Madrid and Paris selected will be "b" "c".
If you add the --separate-output option, it will put
b and c each on a line
of its own, making the result easier to process.
file=$(kdialog --getopenfilename $HOME) file=$(kdialog --getopenfilename $HOME "*.png *.jpg|Image Files") file=$(kdialog --getsavefilename $HOME/SaveMe.png) file=$(kdialog --getexistingdirectory $HOME)