Hello,<br><br>I am working on a fairly well-known ongoing problem where you have a slow logoff if connected wirelessly to a Samba share.<br>You get the message &#39;CIFS VFS: No response ...&#39; and it takes about 2 minutes for the laptop to shutdown.<br>
Apparently it happens because Network Manager closes down before the CIFS mounts are unmounted.<br><br>It will probably be some time before this gets fixed at the root cause but there is a good work-around for Gnome.<br>It entails running a process in the Gnome session that waits for the &#39;save-yourself&#39; event (see below).<br>
<br>Is there a similar closing-down event that can be hooked into with an XFCE session ?<br>Would anyone be able to supply the few lines of code required in main() below ?<br>I could then test and, if successful, post the solution back into the Ubuntu forums article below.  <br>
<br>#!/usr/bin/env python<br><br>#Author: Seamus Phelan<br># <a href="http://ubuntuforums.org/showthread.php?p=8451352#post8451352">http://ubuntuforums.org/showthread.php?p=8451352#post8451352</a><br><br>#This program runs a custom command/script just before gnome shuts <br>
#down.  This is done the same way that gedit does it (listening for <br>#the &#39;save-yourself&#39; event).  This is different to placing scipts <br>#in /etc/rc#.d/ as the script will be run before gnome exits.<br>#If the custom script/command fails with a non-zero return code, a <br>
#popup dialog box will appear offering the chance to cancel logout<br>#<br>#Usage: 1 - change the command in the &#39;subprocess.call&#39; in <br>#           function &#39;session_save_yourself&#39; below to be what ever<br>
#           you want to run at logout.<br>#       2 - Run this program at every gnome login (add via menu System <br>#           -&gt; Preferences -&gt; Session)<br># <br>#<br><br>import sys<br>import subprocess<br>import datetime<br>
<br>import gnome<br>import gnome.ui<br>import gtk<br><br>class Namespace: pass<br>ns = Namespace()<br>ns.dialog = None<br><br>def main():<br>    prog = gnome.init (&quot;gnome_save_yourself&quot;, &quot;1.0&quot;, gnome.libgnome_module_info_get(), sys.argv, [])<br>
    client = gnome.ui.master_client()<br>    #set up call back for when &#39;logout&#39;/&#39;Shutdown&#39; button pressed<br>    client.connect(&quot;save-yourself&quot;, session_save_yourself)<br>    client.connect(&quot;shutdown-cancelled&quot;, shutdown_cancelled)<br>
<br>def session_save_yourself( *args):<br>    #Unmount those CIFS shares!<br>    retcode = subprocess.call(&quot;sudo /etc/init.d/umountnfs.sh&quot;, shell=True)<br>    if retcode != 0:<br>        #command failed  <br>        show_error_dialog()<br>
    return True<br><br>def shutdown_cancelled( *args):<br>    if ns.dialog != None:<br>        ns.dialog.destroy()<br>    return True<br><br>def show_error_dialog():<br>    ns.dialog = gtk.Dialog(&quot;There was a problem running your pre-shutdown script&quot;,<br>
                           None,<br>                           gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT,<br>                           (&quot;There was a problem running your pre-shutdown script - continue logout&quot;, gtk.RESPONSE_ACCEPT))<br>
    if ns.test_mode == True:<br>        response = ns.dialog.run()<br>        ns.dialog.destroy()<br>    else:<br>        #when in shutdown mode gnome will only allow you to open a window using master_client().save_any_dialog()<br>
        #It also adds the &#39;Cancel logout&#39; button<br>        gnome.ui.master_client().save_any_dialog(ns.dialog)<br><br>#Find out if we are in test mode???<br>if len(sys.argv) &gt;=2 and sys.argv[1] == &quot;test&quot;:<br>
    ns.test_mode = True<br>else:<br>    ns.test_mode = False<br><br>if ns.test_mode == True:<br>    main()<br>    session_save_yourself()<br>else:<br>    main()<br>    gtk.main()<br><br>Regards,<br>David Collins<br><br>