How do I add and remove the Workspace Switcher launcher from the Unity launcher?

  1. To disable workspaces completely
    • See @fossfreedom answer https://askubuntu.com/a/211169
  2. To just remove the icon but still preserve workspaces

    • Open the terminal and execute:

      gsettings get com.canonical.Unity.Launcher favorites
      

    the output will be something like,

    ['application://nautilus.desktop', 'application://chromium-browser.desktop', 'application://ubuntu-software-center.desktop', 'application://ubuntuone-installer.desktop', 'application://ubuntu-amazon-default.desktop', 'application://UbuntuOneMusiconeubuntucom.desktop', 'application://gnome-control-center.desktop', 'unity://running-apps', 'unity://expo-icon', 'unity://devices']
    

    To remove the workspaces icon from the dock you should just take out 'unity://expo-icon' from that list. Taking it out, for this case the command should be:

    gsettings set com.canonical.Unity.Launcher favorites "['application://nautilus.desktop', 'application://chromium-browser.desktop', 'application://ubuntu-software-center.desktop', 'application://ubuntuone-installer.desktop', 'application://ubuntu-amazon-default.desktop', 'application://UbuntuOneMusiconeubuntucom.desktop', 'application://gnome-control-center.desktop', 'unity://running-apps', 'unity://devices']"
    

    (Don't forget the double quotes for the list on gsettings set)

Currently I'm using eight workspaces with the help of Unity Tweak Tool. I like to have multiple workspaces, but didn't like the unremovable Unity Launcher icon that much, even more because it could only resemble four workspaces while I was using eight instead.


For 14.04

Drag the undesirable icon on the trash can.

For 13.04

By default, the workspace-switcher is not enabled in the Launcher. This setting is toggleable via the Appearance - Behaviour tab in System Settings

Untick the option shown in the following picture to remove the workspace-switcher icon.

enter image description here

12.10

If you are prepared to work with just one virtual desktop (i.e. no additional workspaces) then the following will work for 12.10 and later.

gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ hsize 1
gsettings set org.compiz.core:/org/compiz/profiles/unity/plugins/core/ vsize 1

Before:

enter image description here

After:

enter image description here


For Ubuntu 11.10 & Ubuntu2D

Edit the file /usr/share/unity-2d/launcher/Launcher.qml with your favorite text editor, ie:

sudo nano /usr/share/unity-2d/launcher/Launcher.qml

For Ubuntu 12.04 & Ubuntu2D

Edit the file /usr/share/unity-2d/shell/launcher/Launcher.qml with your favorite text editor, ie:

sudo nano /usr/share/unity-2d/shell/launcher/Launcher.qml

Locate these lines

    Component.onCompleted: {
        items.appendModel(bfbModel);
        items.appendModel(applications);
        items.appendModel(workspaces);
        items.appendModel(devices);
        shelfItems.appendModel(trashes);
    }

And change them to

    Component.onCompleted: {
        items.appendModel(bfbModel);
        items.appendModel(applications);
/*        items.appendModel(workspaces);*/
        items.appendModel(devices);
        shelfItems.appendModel(trashes);
    }

Ubuntu

Unfortunately the desktop switcher is hard coded to unity and cannot be removed without making source code modifications.

Make sure you have the package dpkg-dev installed

sudo apt-get install dpkg-dev

To modify the code and compile it your self you need to do the following

mkdir ~/code
cd ~/code
mkdir build
cd build
apt-get source unity
cd unity*

Open plugins/unityshell/src/LauncherController.cpp with your favorite text editor, ie:

nano plugins/unityshell/src/LauncherController.cpp

Locate the lines

num_workspaces_ = WindowManager::Default()->WorkspaceCount();
if (num_workspaces_ > 1)
{
  InsertExpoAction();
}

Change them to

/*num_workspaces_ = WindowManager::Default()->WorkspaceCount();
if (num_workspaces_ > 1)
{
  InsertExpoAction();
}*/

Build the package

sudo apt-get build-dep unity
debuild -us -uc

Wait for it to finish and install when done

cd ..
sudo dpkg -i unity*.deb libunity*.deb netbook*.deb