The K Desktop Environment

Next Previous Table of Contents

3. Usage

You are reading a manual, so I conclude that you ran into problems. So take a good advice first:

Now you should feel a bit better, but before you can face what is coming next, you should go to your next bookstore and buy Douglas Adams famous trilogy in 5 books...

Read these five books :-)

I hope you are relaxed and happy now and well prepared for the incredible rest of this hitch hikers guide to KFM.

Keyboard shortcuts.

3.1 Keyboard shortcuts

Back in History                                 ALT + Left
Forward in History                              ALT + Right
One directory up                                ALT + Up
Open a file/directory                           Return
Open a popupmenu for the current file           ESC
Move among the icons                            Left/Right/Up/Down
Select/Unselect file                            Space
Scroll up fast                                  Page Up
Scroll down fast                                Page Down
Scroll right (on WWW pages)                     Right
Scroll left  (on WWW pages)                     Left
Scroll up    (on WWW pages)                     Up
Scroll down  (on WWW pages)                     Down
Copy selected file to clipboard                 CTRL + C
Paste files from clipboard to current directory CTRL + V
Select files by pattern                         CTRL + S
Open a terminal in the current directory        CTRL + T
Open new location                               CTRL + L
Find files                                      CTRL + F
Close window                                    CTRL + W

3.2 How to install new data types

What are data types

A file contains only bits and bytes. One must know how to interprete them to give them a meaning. A usual method to archive this is to look at the filename. If it ends with .gif for example, you assume that it is a GIF image. That's what most desktop environments (further on called DE) do. KFM does this, too, since it is very fast, but not convenient. If the extension is not available one does not know of which data type the file is and that means in turn that KFM does not know which appliaction can deal with the data. So if KFM can not figure out the data type by extension it will have a look in the first bytes of the file and lookup some stuff in its magic file. This is called automatic-mime-type-detection-magic and works quite nice. So if the datatype has an entry in the magic file $KDEDIR/share/mimelnk/magic, then KFM would know that the file MyGirlFriend contains an image.

You must register data types in KFM. This poor little helper of yours must know common extensions of this data type, an icon, some descriptive text, perhaps a default application ( we will learn more about this later ) and the mime type.

What is a Mime Type

Mime types are an internet standard. This standard is a naming scheme for data types. A data types name is devided in two sections. The first one tells about the general kind of data ( image, video, audio, text ... ) and since there are different kinds of text ( C-sources, english text, ... ) and different formats for saving images and so on, the second part tells abou the special format. A good example is image/gif. The first part tell, its an image and the second one tells, it is saved in GIF format.

If you are not shure about the correct mime type, then have a look at the magic file, many many mime types are already registered there.

Usually this chapter is only of interest for system maintainers and application developers. A proper installed KDE should come with all this stuff already done, but some people always want to know how stuff works, so here we go.

The directory $KDEDIR/share/mimelnk contains many subdirectories which correspond to the first section of the mime type names. For example our example image/gif is represented by a file named $KDEDIR/share/mimelnk/image/gif.kdelnk. Every KFM config file has the .kdelnk extension. Sometimes KFM hides this extension, since it does not look very nice.

You will find out sooner or later that the directory structure in your global KDE directory is the same as the one in your ~/.kde directory. As sysadmin on your local Linux box, you may usually want to edit the global configuration, while a user at the universities UNIX cluster may only edit his personal configuration. Everything we say about the $KDEDIR directory here, applies to the ~/.kde directory, too. To edit the global config files in $KDEDIR you need a super users password, for the personal stuff of course not.

Installing new mime types step by step

This chapter could be named installing mime types for dummies since it comes with many nice pictures :-).

In the following we want to see how I installed the image/gif mime type. You dont need to reproduce these steps, since this mime type is already installed. After reading this chapter and after having a look at all the images you should know how to install new ones.

The black numbers on yellow circels in the images correspond to the numbered list under the image.

Open a KFM super user window

On your desktop you will find icons like these:

Now click on this icon to open a new KFM window. Usually this is the correct method, but in some cases we need a super users KFM window. If you want to edit the global config files which are usually only writeable for the super user, you need super user access. If you dont now the super user password, then you are not allowed to change the global configuration anyway, but you can of course edit your user specific configuration without being super user. There are different methods leading to a super user kfm window. You can log out, and log in as root. That is the Windows NT way, so we want to do it better. You could open a kvt window, switch to superuser with su and start kfm -ws now, but it is much easier to hit Alt+F2. Now enter kfmsu. A terminal window pops up, asking you for super users password. Enter it and a KFM window will popup up. Once you have done the following stuff, dont forget to close the KFM super user window again. At this time the terminal will desappear, too. the kfmsu script will allow the super user to access the display and will disallow it afterwards automatically for you.

To start, click once with the left mouse button on Templates folder ( or open a super user KFM window as described above ). Have a look at the files in this directory, you will remember them later in this chapter.

Now open the menu Edit and choose Mime Types ( or Global Mime Types if you want to edit the global configuration ). Now you will see something like this:

Creating a new mime type file

Open the menu File and select New. You may have notice by now that the names in this popup menu correspond to the names in the tamplates folder. This menu gives you quick access to the templates. You can have the same effect by opening the templates folder and doing drag and drop. Now select Mime Type. A window like this one will popup:

Opening the properties dialog

Now press the right mouse button over the new icon and select Properties from the popup menu. A dialog appears:

Now KFM rescans all opened directories because the icons and stuff could have changed. You can force KFM manually to do so by choosing Rescan Bindings in the View menu. Your mime type is now registered and KFM should know about it.

Congratulations, you survived this lesson. Time for a break now :-)

Internals

The config files are very simple and of course human readable. You can have a look at it here:

# KDE Config File
[KDE Desktop Entry]
Type=MimeType
MimeType=image/gif
Icon=image.xpm
Patterns=*.gif;*.GIF;
Comment=Gif images
Comment[de]=GIF Dokument
Comment[nl]=Gif afbeelding

You dont need to understand what this means, since KFM provides a GUI for you, that makes things much easier. Hackers never the less want to know and hack everything, so here is a brief description.

The first line is the header of every KDE config file. The Typeline is included in every KFM config file to distinguish the purpose of the config file. This is followed by the mime types name, the icon, a ; separated list of patterns and comments in english, german, ...

Now the hackers may leave this lesson.

3.3 How to install a new application

Every KDE application should come with its configuration files so there is no need for the user to edit them. But unless every distribution is KDE ready you may want to configure existing applications to work with KDE. In this lesson we try to install XV in the K Desktop Environment.

Why and where

Every application must put a config file in the directory tree $KDEDIR/share/applnk. In addition you have a local directory structure in ~/.kde/share/applnk where you can install additional apps. These files will only be visible for you, not for other users. KFM and KPanel scan these directories on startup. KPanels system menu corresponds to this directory structure. The icons in this directory behave like real applications. You can click on them to start the application and you may drop files on them. It is sometimes a good idea to have such config files outside the applnk tree. They work in every directory, but only the ones in the applnk directory are scanned in on startup. So if you want to install for example XV as the default app for images, then you must move the config file inside this special tree. But perhaps there are some apps which you dont want to appear in KFM or KPanel but on your desktop, then you may of course create such config files on your desktop or elsewhere. The procedure is almost the same as the one we are describing here.

If KFM find a file it first tries to find out about its data type. After doing so it searches all applications which regsitered for this data type. If none is found the user is prompted. If only one is found or a default on was specified, KFM will use this one, otherwise KFM will make a guess. Using the right popup menu will show you a selection of all applications which registered for this data type.

Step by step

You may now continue with the next section while the hackers and developers may want to learn more internals.

The config file we want to create will look like this:

# KDE Config File
[KDE Desktop Entry]
BinaryPattern=xv;
MimeType=image/gif;image/jpeg;image/tiff;image/x-xbm;image/x-xpm;
Comment=XV Image App
Comment[de]=XV Graphik Programm
Exec=xv %f
TerminalOptions=
Icon=image.xpm
Path=
Type=Application
Terminal=0
Name=XV
Name[de]=XV

The first line contains some magic bytes and the second line contains a ; separated list of names that the binary of this application may have. This way the binary gets a nice icon, too. The next line conatins a list of all mime types the app can handle, followed by the usual comments in different languages. the Exec tag contains the shell quoted command that will be executed to start the application. The %f is going to be replaced by the documents filenames, but see the next chapter for more details. The Type tag is needed like in every KFM config file. You can tell KFM to start the app in a terminal by setting Terminal to 1 and by setting some terminal options if needed. In addition the Path tag allows you to specify a working directory. The last two lines determine the name of the applicattion. This name is used in KFMs context sensitive popup menus for example. As with the comments you must provide a english version and may supply diffrent translations.

Secret tips

Most old style apps may need the %f argument. This means that they can only accept files on the local hard disks. If you use URLs never the less, KFM will download the files first and start the application afterwards. If the files are modified by the app, the user is prompted wether he wants them to be uploaded.

You may enter %u instead of %f. This will cause KFM to pass URLs to the application. External files are not preloaded. Some KDE apps support this cool feature.

There are addtional tags you may use. Here is a short list:

3.4 Integrating an application step by step

In this chapter I will show you how to register XV in the K Desktop Environment. After following these steps XV will be registered for various image data types and will be able to load and save images from the web... you did not expect that :-). So, here we go.

Opening a KFM super user window

I assume that you know from the previous lesson how to open a KFM super user window. Now open the menu Edit and select Applications. You will now be shown a window like this one:

If you are logged in as super user you will find an option to edit the global application config files, too

Please distinguish exactly between applications config files and application config files. The first one stores configurations written by an application during run time, while the second ones ( these are the ones we are talking about here ) contain informations about installed applications. These config files are created during installation of an application and dont change usually afterwards.

Creating a new application file

From the menu File open the submenu New and select Program. You will now be prompted by a new window:

Opening the properties

You will now see a new icon in the window. Press the right mosue button to open the properties menu. Now you have to fill out a form like this one:

The second form

The last step is to fill out the second form:

That is the end of the show, your application is registered now. KFM has updated its bindings automatically, only KPanel will need to be restarted ( System menu of kpanel ). XV should now appear in the list of applications once you hit the right mouse button over an image file containing one of the selected data types. If the image is not located on your local hard disk, KFM will download it and run XV afterwards. If the file is modified by XV, KFM will ask you wether it should be uploaded. It is now time for a coffee or two.

3.5 Bookmarks

KFM enlarges the meaning of bookmarks. Bookmarks can refer to every file, that means apart from HTML pages and FTP directories documents, applications and *.kdelnk files. If a bookmark is selected in KFM, the convenient action follows; a document is opened, an application is started etc. To add a file to the collection of bookmarks, you only have to use the right mouse button on the file and select the entry 'Bookmarks'.

Editing Bookmarks

Each bookmark corresponds to a file in $HOME/.kde/share/apps/kfm/bookmarks. An entry in the bookmarks menu makes it easy to find this directory. Renaming a bookmark file also changes the bookmark menu immediately. If you open the properties for such a file, you can configure the bookmark, i.e. for example change the destination (URL) or the icon. You can move, copy and rename files in this directory tree as you desire. Please make sure that these files have a suffix *.kdelnk, so that KFM will easily distinguish them from 'normal' files.

Bookmark Tree

Creating a new directory in $HOME/.kde/share/apps/kfm/bookmarks will create a submenu of the bookmark menu at the same time. To add a bookmark to the new submenu, pop it up. The first entry will add a bookmark for the current URL.

Bookmarks outside KFM

The program krootwm allows the access on the bookmarks. Clicking the right mouse botton on the background of the desktop makes (besides other stuff) the bookmark menu appear. Changings on the bookmarks are not immediately applied to krootwm yet. At the moment you have to restart krootwm to do so.

Next Previous Table of Contents