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.
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.
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.
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:
%k The path and name of the config file itself. This is useful if the app you want to start should read/modify the config file that started it. This way you can for example implement simple printer representations. The same file that repesents the printer on your desktop stores your prefered printer settings. Use %k to pass the config file to the printer GUI.
%n The filename of the documents without path.
%d The path of the documents without file name. The %d and the %n tag together are the same as %f.
%c Name of the application. This is the (possibly translated) title of the application, as set in the kdelnk file. This way you can set the title of the application.