Development/Tools/Using kfmclient: Difference between revisions

From KDE TechBase
(ported page)
 
(Mark for updating)
 
(6 intermediate revisions by 5 users not shown)
Line 1: Line 1:
= Driving Konqueror From Scripts: kfmclient =
{{Review|Update to kioclient5}}
 
= Using kfmclient =


== Introduction ==
== 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.
''kfmclient'' is a tool for opening URL's from the command line, or from scripts. ''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 <code>kfmclient --commands</code>
Note 1: This help is also available from ''kfmclient'' itself, if you run <syntaxhighlight lang="text">kfmclient --commands</syntaxhighlight>
 
Note 2: Since KDE 4, ''kioclient'' was introduced and some of ''kfmclient'' were moved to ''kioclient''. To get ''kioclient'' help, you can run <syntaxhighlight lang="text">kioclient --commands</syntaxhighlight>


== Commands ==
== Commands ==
Line 11: Line 15:
All commands have the general form kfmclient ''command parameters''.
All commands have the general form kfmclient ''command parameters''.


'''kfmclient openURL 'url''''
'''kfmclient openURL 'url' ['mimetype']'''
 
Opens a window showing 'url'. 'url' may be a relative path or file name, such as {{path|.}} or {{path|subdir/}}. If 'url' is omitted, {{path|$HOME}} is used instead.


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.
If 'mimetype' is specified, it will be used to determine the component that Konqueror should use. For instance, set it to text/html for a web page, to make it appear faster.
 
'''kfmclient newTab 'url' ['mimetype']'''
 
Same as above but opens a new tab with 'url' in an existing Konqueror window on the current active desktop if possible.


'''kfmclient openProfile 'profile' ['url']'''
'''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.
Opens a window using the given profile. 'profile' is a file under {{path|share/apps/konqueror/profiles}} (globally or locally). 'url' is an optional URL to open.
New in KDE 2.


'''kfmclient openProperties 'url''''
'''kfmclient openProperties 'url''''


Opens a properties menu
Opens a properties menu.


'''kfmclient exec 'url' ['binding']'''
'''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'
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 {{path|*.desktop}} file. This way you could for example mount a device by passing 'Mount default' as binding to 'cdrom.desktop'


Examples:
'''kfmclient move 'src' 'dest''''


    kfmclient exec file:/root/Desktop/cdrom.desktop "Mount"
Moves the URL 'src' to 'dest'. 'src' may be a list of URLs.


Mounts the CDROM
'''kfmclient download ['src']'''


    kfmclient exec file:/home/weis/data/test.html
Copies the URL 'src' to a user specified location'. 'src' may be a list of URLs, if not present then a URL will be requested.


Opens the file with default binding.
'''kfmclient copy 'src' 'dest''''
Copies the URL 'src' to 'dest'. 'src' may be a list of URLs.
 
'''kfmclient sortDesktop'''


    kfmclient exec file:/home/weis/data/test.html Netscape
Rearranges all icons on the desktop.


Opens the file with netscape
'''kfmclient configure'''


    kfmclient exec ftp://localhost/
Re-read Konqueror's configuration.


Opens new window with URL
'''kfmclient configureDesktop'''


    kfmclient exec file:/root/Desktop/emacs.desktop
Re-read kdesktop's configuration.


Starts emacs
Examples:


    kfmclient exec file:/root/Desktop/cdrom.desktop
kfmclient exec file:/root/Desktop/cdrom.desktop "Mount"


Opens the CD-ROM's mount directory
Mounts the CDROM


    kfmclient exec .
kfmclient exec file:/home/weis/data/test.html


Opens the current directory. Very convenient.
Opens the file with default binding.


'''kfmclient copy 'src' 'dest''''
kfmclient exec file:/home/weis/data/test.html Netscape


Copies the URL 'src' to 'dest'. 'src' may be a list of URLs.
Opens the file with netscape


'''kfmclient move 'src' 'dest''''
kfmclient exec ftp://localhost/


Moves the URL 'src' to 'dest'. 'src' may be a list of URLs.
Opens new window with URL


'''kfmclient sortDesktop'''
kfmclient exec file:/root/Desktop/emacs.desktop


Rearranges all icons on the desktop.
Starts emacs


'''kfmclient configure'''
kfmclient exec file:/root/Desktop/cdrom.desktop


Re-read konqueror's configuration.
Opens the CD-ROM's mount directory


'''kfmclient configureDesktop'''
kfmclient exec .


Re-read kdesktop's configuration.
Opens the current directory. Very convenient.


== Usage example ==
== 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").
Here is a simple example of how you can use the kfmclient interface. It is a simple shell script to open a Konqueror window in the current working directory (I call this script "here").
<code>
<syntaxhighlight lang="bash">
  #!/bin/sh
#!/bin/sh
  exec kfmclient openURL .</code>
exec kfmclient openURL .
</syntaxhighlight>

Latest revision as of 05:36, 2 June 2019

Warning
This page needs a review and probably holds information that needs to be fixed.

Parts to be reviewed:

Update to kioclient5

Using kfmclient

Introduction

kfmclient is a tool for opening URL's from the command line, or from scripts. kfmclient is part of the kdebase package, so you can rely on it's presence on any system running KDE.

Note 1: This help is also available from kfmclient itself, if you run

kfmclient --commands

Note 2: Since KDE 4, kioclient was introduced and some of kfmclient were moved to kioclient. To get kioclient help, you can run

kioclient --commands

Commands

All commands have the general form kfmclient command parameters.

kfmclient openURL 'url' ['mimetype']

Opens a window showing 'url'. 'url' may be a relative path or file name, such as . or subdir/. If 'url' is omitted, $HOME is used instead.

If 'mimetype' is specified, it will be used to determine the component that Konqueror should use. For instance, set it to text/html for a web page, to make it appear faster.

kfmclient newTab 'url' ['mimetype']

Same as above but opens a new tab with 'url' in an existing Konqueror window on the current active desktop if possible.

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.

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'

kfmclient move 'src' 'dest'

Moves the URL 'src' to 'dest'. 'src' may be a list of URLs.

kfmclient download ['src']

Copies the URL 'src' to a user specified location'. 'src' may be a list of URLs, if not present then a URL will be requested.

kfmclient copy 'src' 'dest' Copies 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.

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.

Usage example

Here is a simple example of how you can use the kfmclient interface. It is a simple shell script to open a Konqueror window in the current working directory (I call this script "here").

#!/bin/sh
exec kfmclient openURL .