Programmatically Adding Workspaces in Gnome

If you ever need to add or remove Gnome workspaces using a command-line or a keyboard shortcut, here are the basics required to get it going. Gconf is Gnome’s configuration system. It keeps track of many of your computers settings.

The commands

You can see how many workspaces your desktop currently has using this command:

[code=bash]gconftool-2 –get /apps/metacity/general/num_workspaces[/code]

You can set the number of workspaces with this command:

[code=bash]gconftool-2 –set -t int /apps/metacity/general/num_workspaces 6[/code]

Just change the “6” to the number of workspaces you need. You can increase it to add workspaces, or decrease it to destroy workspaces. Applications in a removed workspace shift left to the first active workspace.

Making it into a command

Below is a command I wrote to easily add ore remove one workspace. Usage: workspace [-add|-remove]


case “$1” in
“-add”    ) method=”+”;;
“-remove” ) method=”-“;;
*         ) echo “Usage: workspace [-add|-remove]”; exit $E_WRONGARGS;;

gconftool-2 –set -t int /apps/metacity/general/num_workspaces $((`gconftool-2 –get /apps/metacity/general/num_workspaces`${method}1));
You can now use it on the command line and/or make a keyboard shortcut to call the script.

I tested this in Ubuntu 10.10, but it should work in any Linux distribution using a recent version of Gnome.

Starting Jungle Disk on boot in Ubuntu

Jungle Disk is a great tool. If you use it with Ubuntu though, you might have a little trouble getting it to run automatically. It comes as an executable file in gz or deb format for Ubuntu, but there is no clear way to set it up at startup.

Adding it in System > Preferences > Startup Applications doesn’t properly load it into the panel, which confuses it and causes it to constantly pop back up when you try minimize it. This was driving me crazy. What’s more, when shutting down or rebooting, Jungle Disk doesn’t cleanly exit and leaves a few session files laying around. This causes an error about multiple copies running when you try to run it on boot.

Fortunately I was able to work around these quirks. I’m happy to report that Jungle Disk is loading and working as expected now. Here is what I did:

  1. Put the following into a text file:
    if [ -f ~/.junglediskworkgroupinstance ]
    rm ~/.junglediskworkgroupinstance;
    if [ -f ~/.com.jungledisk.workgroupservice.status ]
    rm ~/.com.jungledisk.workgroupservice.status;
    sleep 30;
  2. Make the file executable with “chmod 755 /path/to/file” or something similar.
  3. Add the new command to System > Preferences > Startup Applications.

You might change the sleep period for more or less time as needed. 30 seems to work well for me. And I’m sure there are better ways to handle this. If you have a any recommendations, let me know.

VirtualBox: Disable time sync between host and client

If you run VirtualBox you may eventually run into problems with the time or time sync within your VM guest. You can run this command on the host to disable time sync:

vboxmanage setextradata <vmname> “VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled” “1”

Just replace <vmname> with the name of your guest. On Windows hosts, you’ll need to change the command to “VBoxManage”.

You will most likely want to set the client to sync with a time server after this. On Windows clients, just double click on the time and go to the Internet Time tab. Check the box and choose (better reliability).

I needed to solve this because QuickBooks Pro 2000 complains about the system time being changed continuously while in multi-user mode.

I found this simple VirtualBox time sync tip in a post titled Synchronize a Virtualized Domain Controller with External Time Servers.

Synergy keyboard shortcuts on Ubuntu

In a previous post, I wrote about running Synergy on boot in Ubuntu. Synergy also lets you setup keyboard shortcuts for various actions. Below I show how to setup Synergy keyboard shortcuts for switching between computers. Now you can work away without the need to grab the mouse to get from one screen to the next.

  1. Open a terminal and enter
    [code]sudo gedit /etc/synergy.conf[/code]
  2. Add an options section with keystroke lines something like this
    section: options
    keystroke(Alt+1) = switchToScreen(comp1)
    keystroke(Alt+2) = switchToScreen(comp2)
  3. Save the file and exit
  4. Restart Synergy (reboot if you don’t know how to restart otherwise)

You will need to replace “comp1” and “comp2” with your computer names or aliases. These should be listed in the screens section of your synergy.conf. And of course, if you have more than 2 screens, just add more keystroke lines.

You can learn more about Synergy’s options on the Synergy configuration page.

Synergy on boot in Ubuntu

Synergy is a great tool that lets you control multiple computers with one keyboard and mouse. If you use Ubuntu, or another linux distro, it may not be entirely obvious how to get synergy to run on boot. Below are the steps I took:

Update July 3, 2010 – I added client installation instructions and headings that hopefully will clarify a few points.

For an Ubuntu Server:

  1. Install Synergy if you haven’t already
    • Frontend applications like QuickSynergy will install Synergy for you
    • Otherwise, you can go to System > Administration > Synaptic Package Manager, and search for “synergy”
  2. Create your synergy config file
  3. Store the synergy config in /etc/synergy.conf
    • From a terminal type sudo gedit /etc/synergy.conf
  4. Set synergy to run on boot
    • Go to System > Preferences > Startup Applications
    • Add Synergy, entering /usr/bin/synergys (note the s on the end) for the command
    • Reboot to test it out

For an Ubuntu client

  1. Install Synergy if you haven’t already (as in step 1 above)
  2. Make sure the Synergy server is up and running. You can ping it’s hostname or ip address
  3. Set synergy to run on boot
    • Go to System > Preferences > Startup Applications
    • Add Synergy, entering /usr/bin/synergyc <server>
      • note the c on the end of the command
      • <server> is the hostname or IP address you were able to ping in step 2
    • Reboot to test it out

I’m sure there are many other ways to accomplish this. If you are interested in learning more about Synergy, the Synergy-plus project maintains an excellent list of Synergy Related Projects.