Home Download Buy Blog Forum Support

Events for application start/close

Events for application start/close

Postby tbourden on Sat Dec 01, 2012 11:07 pm


is there any way to execute code just before the application start closing or just after the application has been fully started (meaning that last workspace has been restored as well).

I'm trying to do some cleanup / bootstrap for my plugin (change window layouts and close temporary buffers that it uses), but so far I haven't anything that would work as I described above. I was presuming that I could use an EventListener for that, but it only triggers to open/close events of views, not the application itself.
Posts: 4
Joined: Tue Oct 09, 2012 7:13 pm

Re: Events for application start/close

Postby malkomalko on Sat Mar 09, 2013 8:39 pm

I know I'm reviving an old animal here, but does anybody have any information on this? It'd be a really good idea to have a close hook with Sublime 3 (or 2) to be able to cleanup any servers you may've created
Posts: 13
Joined: Sat Feb 02, 2013 12:54 pm

Re: Events for application start/close

Postby wasilto on Sun Oct 20, 2013 3:30 am

i'm interested in that too, though I suppose it's the kind of thing that's built for an OS to do..
e.g. in windows a bat file could do something before it runs, run it, then do something after it runs. Or jscript/vbscript, a .js file or .vbs file, could launch sublime, and do something before and after(with no cmd window popping up). Bear in mind also that an application can be closed with tasklist /f /im blah.exe and it's closed before it knows what hit it. So to really know it has just closed, the wrapper method provided by the OS, OS scripting, seems good.
Posts: 18
Joined: Sat Sep 07, 2013 10:53 pm

Re: Events for application start/close

Postby lunixbochs on Sat Oct 26, 2013 10:27 pm

For open, you can probably use plugin_loaded with an 'already loaded' global variable.

Code: Select all
def plugin_loaded():
    global loaded
    except NameError:
        loaded = True

For cleaning up subprocesses on close, you can fork a subprocess that monitors sublime. If the sublime process disappears, you can do cleanup. This isn't super portable, but you can use third-party modules like psutil to help or check your platform and use ctypes on Windows.
Posts: 92
Joined: Fri Oct 08, 2010 10:18 pm

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests