Development/Tools/Using kfmclient
Driving Konqueror From Scripts: kfmclient
Introduction
kfmclient is a small utility for communicating with Konqueror from the command line, or from scripts. It can control Konqueror to a high degree using an API similar to that provided to C++ programmers by the Konqueror class. kfmclient is part of the kdebase package, so you can rely on it's presence on any system running KDE.
The reason why it's still named kfmclient and not konqclient is so that scripts written for KDE 1.x still run with KDE 2.x
Note that all this help is also available from kfmclient itself, if you run kfmclient --commands
Commands
All commands have the general form kfmclient command parameters.
kfmclient openURL 'url'
Opens a window showing 'url'. 'url' may be a relative path\n" or file name, such as . or subdir/\n" If 'url' is omitted, $HOME is used instead.
kfmclient openProfile 'profile' ['url']
Opens a window using the given profile. 'profile' is a file under share/apps/konqueror/profiles (globally or locally). 'url' is an optional URL to open. New in KDE 2.
kfmclient openProperties 'url'
Opens a properties menu
kfmclient exec 'url' ['binding']
Tries to execute 'url'. 'url' may be a usual URL, this URL will be opened. You may omit 'binding'. In this case the default binding is tried. Of course URL maybe the URL of a document, or it may be a *.desktop file. This way you could for example mount a device by passing 'Mount default' as binding to 'cdrom.desktop'
Examples:
kfmclient exec file:/root/Desktop/cdrom.desktop "Mount"
Mounts the CDROM
kfmclient exec file:/home/weis/data/test.html
Opens the file with default binding.
kfmclient exec file:/home/weis/data/test.html Netscape
Opens the file with netscape
kfmclient exec ftp://localhost/
Opens new window with URL
kfmclient exec file:/root/Desktop/emacs.desktop
Starts emacs
kfmclient exec file:/root/Desktop/cdrom.desktop
Opens the CD-ROM's mount directory
kfmclient exec .
Opens the current directory. Very convenient.
kfmclient copy 'src' 'dest'
Copies the URL 'src' to 'dest'. 'src' may be a list of URLs.
kfmclient move 'src' 'dest'
Moves the URL 'src' to 'dest'. 'src' may be a list of URLs.
kfmclient sortDesktop
Rearranges all icons on the desktop.
kfmclient configure
Re-read konqueror's configuration.
kfmclient configureDesktop
Re-read kdesktop's configuration.
Usage example
Here is a simple example of how you can use the kfmclient interface. It is a simple shell script to open a kfm window in the current working directory (I call this script "here").
#!/bin/sh
exec kfmclient openURL .