Purpose: In our last post on LXDE, we saw how to auto-start a script/program in LXDE as soon as the user logs in. Now in this post, we will learn how to place our own custom programs on LXDE desktop. You must have noticed that you simply cannot drag-and-drop programs on LXDE desktop.

As mentioned earlier that the “.desktop” files are the most important files in LXDE if you want to do a lot of customizations. We will achieve our goal using the “.desktop” file. Let’s assume that you want to place a text file on your desktop which you can double click to open it. Further let’s assume that your text file resides at “/root/” directory.

Step 1: Create a text file

# nano README.TXT
Contents:

Hello, How are you today?

Save and exit.

Step 2: Create a corresponding .desktop file

Now we will create a corresponding .desktop file for the text file that we created in Step 1. Note that all the .desktop file will reside in the /usr/share/applications folder.

# cd /usr/share/applications/
# nano README.desktop

and type the following contents:

[Desktop Entry]
Encoding=UTF-8
Name= README
Comment= My README file
Exec=lxterminal --command "less /root/README.TXT"
Icon=/usr/share/pixmaps/readme.xpm
MimeType=text/plain
Terminal=false
Type=Application
MimeType=text/plain
Categories=Utility

Save and exit.

Let’s take a moment and understand what is going on in the above file:

Name - Give any name you want

Comment – Your own comment

Exec – Basically we are telling which program to use to open our text file. In this case we are opening the text file with “less” command in the lxterminal window. You could have also given the following:

Exec=leafpad /root/README.TXT

Icon – I copied my own icon, readme.xpm, in the “/usr/share/pixmaps” directory. You can do the same or just use the default icons that are available in that directory.

Rest all the fields should generally remain the same.

Step 3: Create a “Desktop” directory


Now we will create a directory called “Desktop” in the user’s home directory. So for example, if the user is “root”, then we will create the directory as follow:

# cd;
# mkdir Desktop

If your user is at “/home/kushalk”, then you would create the directory as follow:

# mkdir /home/kushalk/Desktop

Step 4: Link the .desktop file with Desktop folder

This is the last piece of puzzle which will bring everything together. Now all we need to do is to link the “.desktop” file created in Step 2 inside the “Desktop” directory created in Step 3.

# cd;
# cd Desktop
# ln -s /usr/share/applications/README.desktop .

That’s it. As soon as you give the above coomand, an icon should appear on your Desktop. In case if the icon still does not appear, simply logout from LXDE and log back in.

Happy LXDE’ing!

Be Sociable, Share!