Customize mate menu

Forum rules
Before you post please read how to get help

Customize mate menu

Postby ols on Wed Jan 23, 2013 4:01 pm

Hi all,

How can I remove the "Shutdown ..." menu item from the Mate main menu, for all my users.
I do not want that any normal user is able to shutdown the machine, as it acts as a small server.

I also have a related question. On this machine, if a user open a terminal and enter:
$ halt
the system response is:
halt: Need to be root
So a normal user can not shutdown the system. That is sane.

But he can shutdown the system by clicking in "shutdown ..." mate main menu ... Strange no ?

Thanks for help,

Olivier
ols
Level 1
Level 1
 
Posts: 8
Joined: Tue Jan 22, 2013 2:22 pm

Linux Mint is funded by ads and donations.
 

Re: Customize mate menu

Postby xenopeek on Wed Jan 23, 2013 5:11 pm

Well, you can right-click the menu button, go to preferences, go to the system tab, and disable quit. This will remove the quit button from the menu, but only for one user.

As a quick hack alternative, if you trust nobody, edit the file /usr/lib/linuxmint/mintMenu/plugins/system_management.py as root. Almost at the end of the file you will find this block of code:
Code: Select all
            if ( self.showQuit == True ):
                Button7 = easyButton( "system-shutdown", self.iconsize, [_("Quit")], -1, -1 )
                Button7.connect( "clicked", self.ButtonClicked, "mate-session-save --shutdown-dialog" )
                Button7.show()
                self.systemBtnHolder.pack_start( Button7, False, False )
                self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") )

all you need to do is replace that first line with a false statement (make sure the indentation remains the same, as that is how Python works). For example, change it to:
Code: Select all
            #if ( self.showQuit == True ):
            if ( false ):
                Button7 = easyButton( "system-shutdown", self.iconsize, [_("Quit")], -1, -1 )
                Button7.connect( "clicked", self.ButtonClicked, "mate-session-save --shutdown-dialog" )
                Button7.show()
                self.systemBtnHolder.pack_start( Button7, False, False )
                self.mintMenuWin.setTooltip( Button7, _("Shutdown, restart, suspend or hibernate") )

Now, no matter the personal preference of a user, their quit button won't be shown on their menu. After making the above change, either log out and in again to activate, or do "killall mintmenu".

Note that you can not easily stop a determined person from shutting down your system. You can also do that at the login screen. You can do it with the mate-session-save command shown in above. You can do it by sending a DBus message. You can do it with the Magic SysRq key. And so on, and so on all as a normal unprivileged user. So depends on your users how far you should take this...
User avatar
xenopeek
Level 21
Level 21
 
Posts: 15449
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands

Re: Customize mate menu

Postby ols on Wed Jan 23, 2013 5:34 pm

Thanks for your reply ! I did not know that mate was based on python. Interesting !

For your info, I have install Mint two weeks ago after 10 years of Debian. Very nice distro. But in the last week a user (my wife!) shutdowns two times the system instead of logout !!!
And some people was working on the same machine via xdmcp ...
ols
Level 1
Level 1
 
Posts: 8
Joined: Tue Jan 22, 2013 2:22 pm

Re: Customize mate menu

Postby xenopeek on Wed Jan 23, 2013 5:44 pm

Well, MATE isn't based on Python--it's mostly C--but the mintMenu and other programs developed by the Linux Mint developers, like the Software Manager and Update Manager, are all written in Python. Makes it easy to apply these kind of hacks if needed :wink:
User avatar
xenopeek
Level 21
Level 21
 
Posts: 15449
Joined: Wed Jul 06, 2011 3:58 am
Location: The Netherlands


Return to MATE

Who is online

Users browsing this forum: No registered users and 5 guests