Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #auto-remove-sublime-license-popup
- #Copy the script
- #In ST3, open "Tools --> Developer --> New Plugin ...."
- #Paste the script in the new file created.
- #Save changes. Put ANY name just adding ".py" extension.
- ----------------------------------------------------------------------------------------------------------------
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import sublime_plugin
- import subprocess
- from time import sleep
- import sys
- cl = lambda line: subprocess.Popen(line, shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
- log = lambda message: sys.stderr.write("Log: %s\n" % message)
- sublimeMainWindowTitle = " - Sublime Text (UNREGISTERED)"
- class LicenseWindowKiller(sublime_plugin.EventListener):
- def seek_n_close(self):
- sublimePid = int(cl("""wmctrl -lp | grep "%s" | awk '{print $3}'""" % sublimeMainWindowTitle).decode())
- if sublimePid:
- sublimeMainWindowId = cl("""wmctrl -lp | grep "%s" | awk '{print $1}'""" % sublimeMainWindowTitle).decode()
- sublimeSecondWindowId = cl("""wmctrl -lp | grep %s | awk '{ids[$1]++}{for (id in ids){if (id != "%s"){printf id}}}'""" % (sublimePid, sublimeMainWindowId)).decode()
- if sublimeSecondWindowId:
- sublimeSecondWindowTitle = cl("""wmctrl -lp | grep %s | awk '{print $5}'""" % sublimeSecondWindowId).decode()
- if not sublimeSecondWindowTitle:
- cl("wmctrl -i -c %s" % sublimeSecondWindowId)
- return True
- return False
- def on_pre_save_async(self, *args):
- seek = True
- counter = 10
- while seek:
- sleep(.5)
- counter -= 1
- if counter < 0:
- seek = False
- seek = not self.seek_n_close()
- ----------------------------------------------------------------------------------------------------------------
- # Place this file in ~/.config/sublime-text-3/Packages/User/
- import sublime
- import sublime_plugin
- import subprocess
- from time import sleep
- import sys
- cl = lambda line: subprocess.Popen(line, shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
- log = lambda message: sys.stderr.write("Log: %s\n" % message)
- class LicenseWindowKiller(sublime_plugin.EventListener):
- def run(self, edit):
- pass
- def seek_n_close(self):
- # Get main winids and pid
- out = cl("""wmctrl -Gpl | grep "Sublime Text (UNREGISTERED)" | awk '{print $1, $3}'""").splitlines()
- out = [c.strip() for c in out]
- for c in out:
- win_id, pid = c.split()
- pid = int(pid)
- out_2 = cl("""wmctrl -Gpl | grep '{}' | grep -v '{}' | awk '{{print $1, $6, $7}}'""".format(pid, win_id)).decode().splitlines()
- for c_2 in out_2:
- w2_id, w, h = c_2.split()
- w, h = int(w), int(h)
- if (w, h) == (541, 179):
- title = cl("""wmctrl -lp | grep {}| awk '{{print $5}}'""".format(w2_id)).decode()
- if not title:
- cl("wmctrl -i -c {}".format(w2_id))
- return True
- return False
- def on_pre_save_async(self, *args):
- seek = True
- counter = 10
- while seek:
- sleep(.5)
- counter -= 1
- if counter < 0:
- seek = False
- seek = not self.seek_n_close()
Add Comment
Please, Sign In to add comment