I want to do the same behavior that I got when I right-click in perspective and select a setting to get this window

I want to customize menus and toolbars for my perspective only programmatically.
In fact, I want to remove most menus and toolbars only in my perspective and allow them to appear again when I switch to a different perspective. Could you help me with this?
becks source
share