KDE on the command Line, Part #1

One of the strengths of Linux is the ability of the operating system to work in either graphical user interface mode (aka GUI), like Windows 2000; or command line mode; like DOS.  The reason this is an advantage is that in many cases the addition of GUI components to the interface just add unneeded bulk.  Who needs a GUI on a web server?  The other advantage comes from extensive amount of fine grain flexibility that is possible with the command line.  Something that is simply not possible in a GUI.  For example the grep program (a text processing utility in Unix) has thousands of possible options.  Imagine trying to make a usable  GUI program with literally thousands of options.

One noticeable problem exists.  Historically working on the command line meant that you functionally lost the use of GUI tools when not in GUI mode.  For example, you want to read an entry in your GUI address book but only have command line access to your computer.  One would think you would be out of luck.  In addition, some applications gave you no way to control GUI programs from the command line

However, the superb design and tremendous flexibility of KDE has created an incredible bridge between these two worlds.  For example, want to use your KDE trash can while using the command line?  Try this:

kfmclient move <url> trash:/

kfmclient is a tool for opening and accessing file from the command line.  kfmclient automatically uses your KDE preferences to handle command translation.  Here is another example.  Say you want to open a file with your default KDE application handler (whatever that may be.)

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

or specify your own program to open the file with (even non KDE programs)

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

Why is this useful?  Because kfmclient understands KDE kio and dcop information you can specify anything that you would normally do in Konqueror.  This works particularly well for bash scripting.  Say you want to have a program that opens your remote computers /etc/groups file, over ssh, with THAT computer users default editor?  Here is a quick two line bash program for just such a case:

#!/bin/bash
kfmclient exec fish://192.168.1.25:/etc/groups

It will even open up the username/password dialog for you (don’t forget to check the “remember password” check box to have kwallet store the username and password.)  I gotta go for now, but this is just the tip of the iceberg.