# 6.4. Placing Links on Your Desktop

Placing files on your desktop may shorten the paths you need to enter. However, sometimes it would be nice if you could start KEdit with a commonly edited file already opened in it. And how often do you find yourself frustrated after browsing through endless lists of bookmarks to find a site you visit often? Wouldn't it be nice if everything necessary to deliver you to that site was done automatically after clicking a single icon?

## 6.4.1. Using Templates

Templates provide a convenient mechanism for performing tasks such as those outlined above. Templates can also be used to associate particular file extensions with a specific application. When a file ending in a known extension is double-clicked, the application associated with that extension is automatically started. In short, templates help you get the most out of KDE.

Example: You want to put an icon for visiting the KDE web site on your desktop.

1. Open the Template folder on your desktop. Here, you can see all the templates you can use for creating new links and resources. Ftpurl is a template you can use for creating a link to an FTP site and even to a particular directory. For example, you could create a link straight to ftp://ftp.kde.org/pub/kde/stable to be informed when a new release is available. MimeType is a very powerful tool. Because of its complexity I have decided to explain it in Using MIME types. Program is a general template you can use to start a particular program with an argument. For example, you could use this to start `/usr/src/linux/make xconfig` to configure the kernel. URL is also something general: It is a link to a URL which does not start with http:// or ftp://. Make sure that your link makes sense; kfm cannot handle Quake servers (yet). WWWUrl is the template we will be using now. It creates a link to a specific web site.

2. WARNING:If you started KDE as the system administrator (root), make sure you do not change the templates unless you know exactly what you are doing! If you destroy a template, only a new installation of KDE can recreate it!

3. Drag the WWWUrl to your desktop (if you do not know about how to use Drag and Drop, see Drap & Drop for more information.) When asked, choose Copy to create your own copy of the template you can manipulate.

4. Click on the template copy using the right mouse button and choose Properties.

5. In the dialog box that appears, you will see three tabs: Program, Permission and URL.Change the filename and permissions as needed, then click on the URL tab.

6. In the URL field, you must enter the URL you want to be shown when you click on the icon. For our example, type `http://www.kde.org`.

7. You can click on the Icon to change the icon for this new shortcut.

8. If you are satisfied, click Ok to save your changes.

This will update the icon. When you click on it, you will be transferred to the KDE homepage. I suggest that you play around with templates a bit. They are extremely powerful and can be customized for almost any need.

## 6.4.2. Using MIME Types

MIME Types are very powerful. Employing them, you can easily customize your system such that clicking on a file of a specific type starts the application with which that file type has been associated. For example, all .mod files could be set to start kmodplayer, .html files could open a kfm window showing the file, and a core file can be viewed with the Hex Editor by simply clicking on the core file. Warning: Although MIME types are very powerful, they are not without dangers. Playing around with MIME types as the system administrator (root) can damage a KDE system so severely that cannot be restarted! In this example, you will create your personal MIME style, which is only relevant for you. It will only affect other users if you copy or move it to /opt/share/mimelnk.

To link a certain file type with a particular application:

1. Make sure that the application which you want to link to the file type has an entry in the KDE panel. If it is missing, see Adding Programs to your KDE panel for instructions on how to create an entry.

2. Choose Edit > MIME types in the kfm file manager window.

3. Think about the type of file for which you want to create an entry. By default, there are five top level types: Application is for files that are usually created or edited with one specific application, for example, tar, gzip, and pdfs. Audio is for everything that generates any kind of tones: waves, midis, mods, etc. Image is for any graphics files like gif, jpeg or tiff. Text is for everything that is text, for example, plain text, html, C and Pascal source code, tex documents and tcl scripts. Finally Video is for any type of video streaming like mpeg. Decide to which category your type belongs and change to the matching directory.

4. Open the Template folder, which is accessible as an icon on your desktop.

5. Drag & Drop the Mimetype icon into the other window and copy it.

6. Right click the copied icon and select Properties. Edit the properties of your type.

7. Click on Binding. You will now see a mask which requires five entries.

8. The first field must be filled with the file suffix. For example, if you want to create a new type for SGML documents, you should type *.sgml; *.SGML; here. Any file ending with .sgml or .SGML will now be handled with the new type.

9. Enter a description for the type in the Comment field. For the SGML example, it could be "SGML document"

10. Enter the MIME type. It is built with the directory (text/ for the SGML example) and a name you choose. For the SGML example, you would enter text/sgml as the Mime-Type. KDE will inform you if there already is a convention on which prefix to use for your type. The kfm web browser will also depend on this setting when you download a document of this type from the web!

11. Choose an application that is used to edit this file from the dropdown box. For the SGML example, we simply use the Editor.

12. Click on the icon to choose an icon. Every file matching the suffix you entered will appear with this icon when shown in the file manager window.

13. Click Ok to save the new type.

Try your new association by opening a directory containing a file of the type you just selected. Click on the file, and the program needed to edit it should start. If something goes wrong or your system cannot even start anymore, use a text console (or kdm's emergency shell function) to delete the link. That should make everything fine.

## 6.4.3. Defining Your Own Templates

By default, KDE provides you with five default templates which can build new links on your desktop. However, sometimes you will want to create a new template. Doing this is simple:

1. Login with root privileges.

2. Create the file as usual.

3. Move or copy it into the Template folder.

4. Whenever you want to reuse your new template, copy it from the template folder onto your desktop or into a directory, rename it, and use it. Since the Template folder is only writable by you, nobody can accidentally destroy the template (that is, if he or she is not you. It might be a good idea to prevent even you from being able to write to this file, to avoid accidentally damaging it).