Removing shutdown and sleep button from the Apple menu on Mavericks

I'm trying to remove the "Sleep" and "Shutdown" entries from the Apple menu. So far I managed to do it by editing /System/Library/Frameworks/Carbon.framework/Frameworks/HIToolbox.framework/Versions/A/Resources/English.lproj/StandardMenus.nib/objects.xib but that solution is quite ugly. It can be a cause of some instabilities?

I tried the following commands:

sudo defaults write /Library/Preferences/com.apple.loginwindow ShutDownDisabled -bool true
sudo defaults write /Library/Preferences/com.apple.loginwindow ShutDownDisabledWhileLoggedIn -bool True

but they don't seem to work anymore (I used this in Mountain Lion). I wondered if there was any better way to do disable those entries.


Solution 1:

Not sure about Shut Down but you can disable Sleep using pmset:

sudo pmset -a disablesleep 1

This will gray out the Sleep menu item as well.

Source: OS X Server: How to prevent sleep