Saturday, November 3, 2007

Script for Removing GNOME Panel Applets

I was playing around with the GNOME Swallow applet. It's a nice little toy that can "swallow" non-applet applications into the GNOME panel. I used it to convince wmforkplop and wmhdplop to show up in the bottom panel, and then decided it would be nicer to have them on the top panel.

I didn't realize at the time, but it turns out that hitting "cancel" on the swallow applet configuration dialog box, doesn't remove the applet from the panel - it only leaves it un-configured. The only way to actually remove it (when it's not configured) is by directly editing the list of panel applets that's kept in the GNOME configuration database. This can be done manually using gconf-editor, but following this guide I came up with a script to get rid of all the swallow applets on the bottom panel:

#! /bin/sh
applets=`gconftool-2 --get /apps/panel/general/applet_id_list | sed -r -e s/[][]*//g -e s/,/\ /g`
for applet in $applets ; do
bonobo_iid=`gconftool-2 --get /apps/panel/applets/${applet}/bonobo_iid`
if [ ${bonobo_iid} == "OAFIID:GNOME_Swallow" ]; then
echo $applet
panel=`gconftool-2 --get /apps/panel/applets/${applet}/toplevel_id`
if [ ${panel} == "bottom_panel_screen0" ]; then
new_applets="["`echo ${new_applets} | sed -r -e s/,+/,/g -e s/^,// -e s/,$//`"]"
gconftool-2 --set -t list --list-type=string /apps/panel/general/applet_id_list ${new_applets}

This probably took longer then it should have, but at least I learned something.

1 comment:

  1. Thank you! This is exactly what I was looking for!