diff --git a/rsub.py b/rsub.py index 5a77246..811fc1b 100644 --- a/rsub.py +++ b/rsub.py @@ -3,6 +3,7 @@ import os import tempfile import socket + from threading import Thread try: import socketserver @@ -20,6 +21,7 @@ SESSIONS = {} server = None +WINDOW_HANDLE = 'sublime_text.Sublime_text' def say(msg): @@ -85,6 +87,7 @@ def send_save(self): self.socket.send(b"\n") def on_done(self): + global WINDOW_HANDLE # Create a secure temporary directory, both for privacy and to allow # multiple files with the same basename to be edited at once without # overwriting each other. @@ -135,7 +138,7 @@ def on_done(self): 'tell app "Finder" to set frontmost of process "Sublime Text" to true') elif(sublime.platform() == 'linux'): import subprocess - subprocess.call("wmctrl -xa 'sublime_text.sublime-text-2'", shell=True) + subprocess.call("wmctrl -xa '%s'" % WINDOW_HANDLE, shell=True) class ConnectionHandler(socketserver.BaseRequestHandler): @@ -186,7 +189,7 @@ def on_close(self, view): def plugin_loaded(): - global SESSIONS, server + global SESSIONS, WINDOW_HANDLE, server # Load settings settings = sublime.load_settings("rsub.sublime-settings") @@ -200,4 +203,5 @@ def plugin_loaded(): # call the plugin_loaded() function if running in sublime text 2 if (int(sublime.version())< 3000): + WINDOW_HANDLE = 'sublime_text.sublime-text-2' plugin_loaded()