Ubuntu – How to remove the switch user account option in Unity 2D

unity-2d

We are looking for a way to permanently remove the Switch User Account function from our install of Ubuntu Unity. Note, this function appears when you right or left click on the user name in the upper right-hand corner. It then displays a list of 5-10 users that have logged in along with the option to Switch User Account. We know that we can do this by defaulting to gnome, but we would like the option of using Unity as well, but without the Switch User Account option.

We have already tried dconf-editor, gsettings and several other options to remove the users name list, Switch User Account option from appearing in the drop-down list. We know this can be done for one user at a time, but we are wanting to do this for all users on roughly 160 workstations.

Some options that we have already tried are:

This is a visual of what we are trying to remove:

!

Best Answer

Have you tried editing the /usr/share/glib-2.0/schemas/com.canonical.indicator.session.gschema.xml file simply changing this:

<key type="b" name="user-show-menu">
  <default>true</default>
  <summary>Determine the visibility of the User Menu</summary>
  <description>Allow for the user menu to be hidden by the user.</description>
</key> </code>

to this (true to false):

<key type="b" name="user-show-menu">
  <default>false</default>
  <summary>Determine the visibility of the User Menu</summary>
  <description>Allow for the user menu to be hidden by the user.</description>
</key>

Then make a backup of /usr/share/glib-2.0/schemas/gschemas.compiled Then run

sudo glib-compile-schemas /usr/share/glib-2.0/schemas

Normally this would set it as default for all users.

UPDATE:

Florian Diesch pointed out in the comments that it is better to write an override file, because the .xml could be overwritten in an update, thus or settings will be lost. So instead of directly modifying the gschema.xml make a /usr/share/glib-2.0/schemas/myoverride.gschema.override file with the following contents:

[com.canonical.indicator.session]
user-show-menu=false

The rest is the same: backup and compile.