SLED10SP1 Gnome Panel Icon

From CoolSolutionsWiki

Contents

How to add an icon to SLED 10 SP1 panel

Preface

Isn't adding an icon as simple as dragging and dropping? Yes and no. You can drag and drop an icon, which works for a few users. But you will need a more automated process for large deployments unless you have an abundance of free time.

How to add a panel icon without dragging and dropping

This procedure will let you script adding an icon. You will need to drag and drop, but only the firs time.

Create icon and dump data

  1. Create a user who's panel can be reconfigured as desired
  2. Create a launcher on user's desktop for desired panel icon
  3. Drag icon to the panel
  4. Logout user
  5. Startup another user session
  6. cd /home/user_whos_panel_we_modified
  7. gconftool-2 --dump /apps/panel > panel.entries

At this point we have all the information for this user's panel, which includes the new icon. Here is the tricky part. We have the new panel icon information in the file "panel.entries" but we don't have a great way to find it. This icon is named non-intuitively.

To solve this, we will need to search for whatever name gnome generated for our .desktop file:

# find /home/user_whos_panel_we_modified | grep \.desktop$

At this point, we will want to relocate this file to a proper, system wide directory. I would recommend:

# mv /home/user_whos_panel_we_modified/.gnome2/panel2.d/default/launchers/newIcon.desktop /usr/local/share
# chmod +r /usr/local/share/newIcon.desktop

NOTE: This .desktop file will be found from the listings from our 'find' command, so cutting and pasting this verbatim will not copy the file over. You will also want to rename the file as it was probably named something system generated which doesn't make much sense. To rename the file, in the previous move command (mv) you can just change the destination to the new file name (ie /usr/local/share/myLauncher.desktop)

Edit panel.entries

  1. Open the file in your favorite text editor (If you don't have a favorite, use gedit)
  2. Search for the filename from the find command above
  3. Do a search / replace and replace all instances of that name with the new name you picked because of the NOTE above
  4. Change the location of the launcher. You want to search for the string 'launcher_location'
    1. Search for 'launcher_location'
    2. Find the launcher location portion that corresponds to the icon we added
    3. Update the <value><string> under it to reflect the file location, ie:
<value>
 <string>file:///usr/local/share/newIcon.desktop</string>
</value>

Script it

At this point, we have a modified panel.entries file which contains the configuration for the new icon. To distribute this new setup, I personally used ZLM 7.2 (Zenworks Linux Management) and created a policy to install from a script. If you don't have ZLM, you could use ssh / scp to send the file to client stations.

An example script

Here is an example script that I use on deployed systems (replace customIcon.desktop and test.py with real data):

#!/bin/bash

echo ----------------------------------------------
echo Locking down gconf settings
echo ----------------------------------------------
echo

echo '* Creating desktop icons'
mkdir -p /usr/local/share

echo ' - Adding custom icon'
cat > /usr/local/share/customIcon.desktop << _EOF_
[Desktop Entry]
Version=1.0
Encoding=UTF-8
Name=No name
Type=Application
Exec=sudo /usr/local/bin/test.py
TryExec=
X-GNOME-DocPath=
Terminal=false
Name[en_US]=Shutdown
GenericName[en_US]=
Comment[en_US]=Shutdown or reboot the system
Icon=/opt/gnome/share/icons/Tango/48x48/actions/system-shutdown.png
_EOF_

echo '* Creating panel settings file'
cat > /usr/local/share/panel.entries << _EOF_
*** PASTE THE CONTENTS OF YOUR PANEL.ENTRIES HERE, THE ONE WE HAD IN GEDIT EARLIER
_EOF_

echo '* Importing settings'
gconftool-2 --direct --config-source xml:readwrite:/etc/opt/gnome/gconf/gconf.xml.mandatory --load /home/autologin/panel.settings
gconftool-2 --direct --config-source xml:readwrite:/etc/opt/gnome/gconf/gconf.xml.mandatory --type bool --set /apps/panel/global/locked_down true
gconftool-2 --shutdown
reboot

That is just an example, you will need to tweak it for your specific deployment. You can see that in this configuration, I setup the panel, then lock it down, so the user can't change settings.

Where to go from here

Resources

If you need help, first contact your Novell consultant, as you are probably already paying them to figure this stuff out for you. If you get stuck, you can email me at sharms AT ubuntu.com and I will see what I can do to help.