Ubuntu – How to configure the gnome panel from a script

gconfgnome-classicgnome-panel

I can easily set the number of workspaces and the workspace names with the gconftool-2, as follows:

  gconftool-2 --type int --set /apps/metacity/general/num_workspaces 4
  gconftool-2 --type string --set /apps/metacity/workspace_names/name_1 Dev
  gconftool-2 --type string --set /apps/metacity/workspace_names/name_2 Docs
  gconftool-2 --type string --set /apps/metacity/workspace_names/name_3 VM
  gconftool-2 --type string --set /apps/metacity/workspace_names/name_4 Web

However, for some reason I am unable to use similar techniques to set the number of rows in the workspace switcher, or set the preference to show workspace names. I am similarly unable to add applets and launchers via gconftool. I would also like to be able to configure my system to have just one panel at the bottom of the screen. (Solved this much)

I have reviewed the using gconf page without success. For some options, I have been successfully able to find the option name by dumping gconftool-2 -R / to a file, change the option via the GUI, and then dump again and diff. This technique was not fruitful with the above mentioned items. I have also tried –dump and –load, and have tried restarting gnome-panel and gconfd-2, but that does not help either. Is there some other mechanism besides gconftool-2 that the panel uses for storing settings?

I am currently using 11.10 in gnome-classic mode.

Update: Found a script to hide panels.

Update 2: An easier way to remove the top panel:

gsettings set org.gnome.gnome-panel.layout toplevel-id-list "['bottom-panel']"

I actually still cannot configure the panel with dconf.

I can change an existing panel item to point to a different program via dconf write /org/gnome/gnome-panel/layout/objects/object-6/instance-config/location "'...'", but killall -HUP gnome-panel is also required.

If I try to remove an item from the panel via dconf write /org/gnome/gnome-panel/layout/objects/object-id-list "[...]", the contents of the panel do not change, even after restarting gnome panel.

If I make the same change with dconf-editor, it changes immediately.

What do I need to do to update the panel after dconf write?

(Note: behaves the same way under 12.04)

Best Answer

Although gsettings cannot change schemaless keys in dconf, dconf can. You do not need to write your own program. What you can do to change the number of rows in the workspace switcher is:

  1. install the dconf-tool package
  2. run dconf as

    dconf write /org/gnome/gnome-panel/layout/objects/workspace-switcher/instance-config/num-rows 2

You can play with lots of other gnome-panel entries with dconf-editor as well.