-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchromerefresh.py
40 lines (33 loc) · 1.47 KB
/
chromerefresh.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import sublime, sublime_plugin, subprocess, os
PLUGIN_PATH = os.path.dirname(__file__)
class SaveListener(sublime_plugin.EventListener):
def on_post_save_async(self, view):
settings = view.window().settings()
if settings.get('chrome_refresh_onsave_enabled', False):
if settings.has('cr_url'):
subprocess.call(['/usr/bin/osascript', PLUGIN_PATH+'/chromeopen.scpt', settings.get('cr_url')])
else:
subprocess.call(['/usr/bin/osascript', PLUGIN_PATH+'/chromerefresh.scpt'])
class ChromeRefreshCommand(sublime_plugin.ApplicationCommand):
def __init__(self):
self.path = os.path.dirname(__file__)
def run(self):
settings = sublime.active_window().settings()
if settings.has('cr_url'):
subprocess.Popen(['/usr/bin/osascript', PLUGIN_PATH+'/chromeopen.scpt', settings.get('cr_url')])
else:
subprocess.Popen(['/usr/bin/osascript', PLUGIN_PATH+'/chromerefresh.scpt'])
class ChromeRefreshEnableCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.settings().set('chrome_refresh_onsave_enabled', True)
class ChromeRefreshDisableCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.settings().set('chrome_refresh_onsave_enabled', False)
class ChromeRefreshSetUrlCommand(sublime_plugin.WindowCommand):
def run(self):
self.window.show_input_panel("Associate url:", "http://localhost:8000/", self.on_done, None, None)
def on_done(self, url):
if url:
self.window.settings().set('cr_url', url)
else:
self.window.settings().erase('cr_url')