For Ubuntu 14.04 and 16.04 (Unity)
gsettings to disable most of menu items in indicator session menu and use
systemctl to disable suspend ability itself at systemd level. This solution is not perfect, though.
How to disable menu items
To begin with, look for relevant keys using
gsettings command and filter with
grep command. Use "session" and "menu" for keywords to filter twice.
$ gsettings list-recursively | grep session | grep menu
com.canonical.indicator.session suppress-logout-menuitem false
com.canonical.indicator.session force-restart-menuitem false
com.canonical.indicator.session suppress-restart-menuitem false
com.canonical.indicator.session suppress-shutdown-menuitem false
com.canonical.indicator.session user-show-menu true
gsettings to set relevant keys with value that is opposite to current values i.e. "false" becomes "true", vice versa. Run the following commands, one by one.
$ gsettings set com.canonical.indicator.session suppress-shutdown-menuitem true
$ gsettings set com.canonical.indicator.session suppress-restart-menuitem true
$ gsettings set com.canonical.indicator.session suppress-logout-menuitem true
$ gsettings set com.canonical.indicator.session user-show-menu false
suppress-logout-menuitem key to take effect, user may need to reload Unity desktop (run
unity command in Terminal or HUD command prompt, no need to log out or anything).
And that is all needed to do for hiding most of menu items.
Following above steps, all menu items are now hidden in indicator session menu except for "Suspend" menu item. There is an open bug regarding the inability to hide the Suspend menu item. Confirming and subscribing to it may encourage it's resolution.
Given that the menu item cannot be suppressed directly, the next easiest solution is to disable any suspension at system-wide level.
How to disable suspend in Ubuntu 14.04 (Unity, upstart)
In 14.04 release, there are several ways to disable suspension i.e. edit configuration files for
pm-utils. But there is no clarification of which will actually work properly.
How to disable suspend in Ubuntu 16.04 (Unity, systemd)
In 16.04 release, disable any suspension with systemd as noted on Debian Wiki.
$ sudo systemctl mask sleep.target suspend.target hibernate.target hybrid-sleep.target
Created symlink from /etc/systemd/system/sleep.target to /dev/null.
Created symlink from /etc/systemd/system/suspend.target to /dev/null.
Created symlink from /etc/systemd/system/hibernate.target to /dev/null.
Created symlink from /etc/systemd/system/hybrid-sleep.target to /dev/null.
systemctl command will take effect immediately. No need to reboot or anything.
As a result, whenever the "Suspend" menu item is clicked, the system does not go to sleep but only cause the screen to turn blank and returned to login screen (similar effect to "Lock Screen").
Workaround for known issue after suspend
Even without actual suspension, the same known issue will arise when resuming current session: Network manager does not wake up after suspend. The workaround is to restart the service.
$ sudo systemctl restart network-manager.service
The network manager will be restarted and networking will be available again.
Tested all above working in Ubuntu 16.04 (Unity), fresh installed in VirtualBox.