O'Reilly logo

Linux Annoyances for Geeks by Michael Jang

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

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 OpenOffice.org 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 OpenOffice.org Writer.


    The full path to the application—in 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 http://people.fruitsalad.org/phil/kde/userguide-tng/.

  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]

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.

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 OpenOffice.org 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 OpenOffice.org Writer, which is the name I want to see on the desktop.

  3. In the Comment text box, I added a simple description—in this case, The OpenOffice.org Word Processor.

  4. In the Command text box, I added the full path to the command that starts the OpenOffice.org Writer—in 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 openoffice.org 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 OpenOffice.org Writer.

  8. I clicked OK and saw the OpenOffice.org 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.

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.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required