Section 1.4. I d Like Desktop Icons for My Applications

1.4. I'd Like Desktop Icons for My Applications

Creating and locking GUI desktop icons is a straightforward process and is one more thing that you can do to configure a consistent look and feel for the GUI desktops in your office. In general, the easiest way to lock the icons on the desktop is by assigning appropriate ownership on the ~/Desktop directory. What you do may vary slightly if you're using the KDE Desktop Environment or SUSE Linux Professional.

1.4.1. KDE Desktop Icons

You can easily configure a standard set of desktop icons for the KDE Desktop Environment either within the GUI or from the command line. To use the GUI, right-click on the desktop and select Create New File Link to Application. You can then create the desktop icon that you need from the properties menu that appears.

To create a desktop icon from the command-line interface, use a procedure such as the following. Essentially, you will use an existing text file that configures a desktop application as the model for one customized for your new application. For this example, I added a desktop icon for the Writer as follows:

  1. KDE icons are stored in each user's Desktop/ subdirectory. I have an existing Clock icon file, which I've copied with the following commands:

     cd /home/michael cp Desktop/Clock.desktop Desktop/OpenOffice\ Writer.desktop 

  2. I opened the newly created OpenOffice Writer.desktop file in a text editor. The minimum directives I needed to change to make the file work for a new application were:


    What you see on the desktop, which I set to Writer.


    The full path to the applicationin this case, /usr/bin/oowriter.


    The file containing the icon to be displayed. Unless you know the default directory (which varies by distribution), it's best to specify the full path to the icon of your choice. In my case on SUSE Linux, I used /usr/share/pixmaps/ooo-writer.png.

    For more detailed information on the KDE Desktop, see the KDE User Guide, available from

  3. I saved my changes. You may need to log out and log back in to KDE to see the changes. Test your new icon.

  4. For future users, I copied the contents of my personal Desktop/ subdirectory to /etc/skel, so all new users get the same subdirectory.

     cp -a /home/michael/Desktop /etc/skel/ 

  5. I ran the chown command on the Desktop/ subdirectory to assign ownership to root, so the icons can't be changed by new users.

Once you're satisfied with your icons, add the following to the kdesktoprc configuration file:

 [KDE Action Restrictions][$i] editable_desktop_icons=false 

The location of kdesktoprc varies by distribution. On Red Hat/Fedora, it's in /usr/share/config; on SUSE, it's in /opt/kde3/share/config; on Debian, it's in /etc/kde3. Once configured, all you need to do is copy this file to other servers that contain your user's home directories. Alternatively, you can use the individual configuration directory for each user, which happens to be consistent for all three distributions: ~/.kde/share/config/kdesktoprc.

Whatever your selection, check the result. The next time you start the KDE Desktop, right-click on the screen. Notice how the pop-up menu has changed. Right-click on an icon. See how that pop-up menu has changed. If you made the change of ownership recommended in the procedure, you won't be able to use the Create New option. Generally, all you can do once you've made this change is click on the icon to open the associated application, directory, or linked file.

For more information on restricting actions on KDE, see the "My Users Mess Up Their Desktops" annoyance.

1.4.2. GNOME Desktop Icons

As with KDE, you can configure a standard set of desktop icons for the GNOME desktop environment through its GUI. For example, I added a desktop icon for Writer with the following steps:

  1. In the GNOME desktop environment, I right-clicked on the desktop. In the pop-up menu that appeared, I clicked Create Launcher to open the Create Launcher window.

  2. In the Name text box, I entered Writer, which is the name I want to see on the desktop.

  3. In the Comment text box, I added a simple descriptionin this case, The Word Processor.

  4. In the Command text box, I added the full path to the command that starts the Writerin this case, /usr/bin/oowriter.

  5. I didn't change the type, as this word processor is an application. However, I could have set the type to a directory, a link, or a filesystem device (FSDevice) for directories mounted on specific devices. The other options in this drop-down box are not used.

  6. Now it was time to configure this launcher with an icon to be shown on the desktop. I know that there's an ooo_writer.png icon available from the package. So I clicked on the icon and navigated to the associated location. When successful, the icon is shown in the Create Launcher window.

  7. If I were configuring a command-line application such as the vim editor, I'd want to run it in a terminal. However, that's not appropriate for a GUI application such as Writer.

  8. I clicked OK and saw the Writer icon appear on my desktop. I can click on this icon to open the word processor.

  9. I continued creating any more icons that I need.

  10. Once complete, I froze the configuration. I changed the permissions on the files in the ~/Desktop/ directory with the following command (my home directory is /home/michael):

     chmod 400 /home/michael/Desktop/* 

    And then I changed ownership on the ~/Desktop/ directory. The following command takes ownership, and the ability to change any files contained within, from any regular user.

     chown root.root /home/michael/Desktop 

    Now, if I try deleting any icon, I get an error message. While users can still right-click to change permissions, this helps preserve a standard desktop. Other issues are discussed in the following section.

  11. Then I wanted to add the same icons to other users' desktops on this server. I could do so with a command similar to:

     find /home/*/Desktop -maxdepth 0 -exec cp /home/michael/Desktop/* '{}' ';' 

    This command copies all files, but no directories, from /home/michael/Desktop to every user's Desktop/ subdirectory.

  12. I also needed to change the ownership and permissions of each user's Desktop/ subdirectory, as I did with my own. Fortunately, that command is simpler; all I needed was the proper wildcard to make sure ownership and permissions were changed on the ~/Desktop directory of all users (the -R ensures that the changes are made recursively through Desktop/ subdirectories):

     chown -R root.root /home/*/Desktop chmod -R 770 /home/*/Desktop 

  13. For future users, I copied the contents of my personal Desktop/ subdirectory to /etc/skel, so all new users get the same subdirectory.

     cp -a /home/michael/Desktop /etc/skel/ 

  14. Finally, I applied the chown command to the Desktop/ subdirectory to make sure icons aren't changed by new users.

1.4.3. Special Problem: Customizing SUSE Desktop Icons

SUSE presents special problems for custom desktop icons. When you customize the SUSE Desktop as described earlier, it works on KDE. However, changing ownership of each user's Desktop/ subdirectory to root renders the icons unusable on GNOME.

The solution is to change the permissions on SUSE Desktop icons without changing ownership to root. You can then keep users from changing the permissions on their icons, courtesy of the immutable flag.

Specifically, to add the immutable flag to the files in my Desktop/ subdirectory, I ran the following command:

 chattr +i /home/michael/Desktop/* 

Extend this to all users with the following command:

 chattr +i /home/*/Desktop/* 

The Linux kernel has recently included support for chattr on SUSE's default filesystem, ReiserFS.

Linux Annoyances for Geeks
Linux Annoyances for Geeks: Getting the Most Flexible System in the World Just the Way You Want It
ISBN: 0596008015
EAN: 2147483647
Year: 2004
Pages: 144
Authors: Michael Jang © 2008-2017.
If you may any questions please contact us: