Page 1 of 1

Customize behavior of shutdown and reboot in mintMenu

Posted: Sun Oct 09, 2011 12:24 pm
by wjstarrsiii
Hello,

I have two laptops at home and one that I built for my parents that are used in a mixed Mint / Win environment. I have an iomega NAS that I mount various directories using CIFS in fstab. There is a known bug where gnome shuts down the wireless before the CIFS are unmounted, and this causes a lockup that requires holding the power button down for 5 seconds for each restart / shutdown.

I found a script online to find these mounted drives and unmount them. I wrote 2 tiny bash scripts to call this and then shutdown or restart:

sudo /etc/init.d/umountnfs.sh && sudo shutdown -r now

or

sudo /etc/init.d/umountnfs.sh && sudo shutdown -h now

I softlinked these to ./rs and ./sd , I am comfortable with the terminal and running these with alt-F2. I updated sudoers to allow me to execute these with no password.

My wife and parents are not so savvy. My goal is to tie the shutdown or restart buttons in mintMenu to these scripts so everything "just works" for them. The menu editor does not seem to provide access to the more "core" functions in the menu. Any suggestions on how to accomplish this?

Thanks in advance,

wjstarrsiii

Re: Customize behavior of shutdown and reboot in mintMenu

Posted: Tue Jun 19, 2012 1:45 pm
by rj.adams
You can customize the shutdown action by editing the corresponding script, either in MATE or CInnamon.

MATE:

Code: Select all

/usr/lib/linuxmint/mintMenu/plugins/system_management.py

Example: (search for "shutdown-dialog" and follow the indentation in the file closely)

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.connect( "clicked", self.ButtonClicked, "/usr/local/bin/customShutdown.sh" )
Cinnamon:

Code: Select all

/usr/share/cinnamon/applets/menu@cinnamon.org/applet.js
Example: (search for "ShutdownRemote")

Code: Select all

         //Shutdown button
         let button = new SystemButton(this, "gnome-shutdown", launchers.length + 3);        
         button.actor.connect('enter-event', Lang.bind(this, function() {
            this.selectedAppTitle.set_text(_("Quit"));
            this.selectedAppDescription.set_text(_("Shutdown the computer"));
         }));
         button.actor.connect('leave-event', Lang.bind(this, function() {
            this.selectedAppTitle.set_text("");
            this.selectedAppDescription.set_text("");
         }));        
         button.actor.connect('clicked', Lang.bind(this, function() {            
            this.menu.close();
            Util.spawnCommandLine("/usr/local/bin/customShutdown.sh"); // add something like this
            //this._session.ShutdownRemote(); // comment this out
         }));
Be careful with your edits or you will potentially lose your menu due to a syntax error or in the case of Cinnamon, possibly be unable to log-in. If this happens, you can always undo your changes by switching to a virtual terminal (Ctrl+Alt+F1), and issuing a

Code: Select all

sudo apt-get install --reinstall cinnamon
or

Code: Select all

sudo apt-get install --reinstall mintmenu
before switching back with a Ctrl+Alt+F7 (or F8).

Cheers!

Re: Customize behavior of shutdown and reboot in mintMenu

Posted: Tue Jun 19, 2012 2:21 pm
by remoulder
@rj.adams: please do not post against old posts. Your reply is probably not relevant to the op as it could have been referring to a completely different version of mintmenu.

Re: Customize behavior of shutdown and reboot in mintMenu

Posted: Tue Jun 19, 2012 2:56 pm
by rj.adams
remoulder wrote:@rj.adams: please do not post against old posts. Your reply is probably not relevant to the op as it could have been referring to a completely different version of mintmenu.
The post may be over a year old but the topic is still relevant as I found this thread while searching for how to accomplish the same thing. I should have noted this.

As to the version, it's been 3 years since mintmenu first included the code referenced so the OP may use a different version but it should work just the same.

I appreciate your concern but just because a thread is 1.5 years old does not make it irrelevant, especially when it is still available via search engines and refers to an application still shipped with Mint today.

Re: Customize behavior of shutdown and reboot in mintMenu

Posted: Tue Jun 19, 2012 7:36 pm
by remoulder
rj.adams wrote:just because a thread is 1.5 years old does not make it irrelevant
Please read the forum rules Section II point 2.

Re: Customize behavior of shutdown and reboot in mintMenu

Posted: Tue Jun 19, 2012 8:03 pm
by rj.adams
remoulder wrote:Please read the forum rules Section II point 2.
With all due respect, Section II contains guidelines. If it was a rule, it might be accompanied by the auto-closing and possible deletion of unanswered support threads older than six months. In my opinion there is no harm in answering a question that is still relevant today. The OP might have moved on but I posted my response thinking it may be of help to others looking for an answer instead of just an open question (as I did). Yes I could have created my own thread but this is the one I found via Google and DuckDuckGo. Cheers.