Virajsinh

Sublime License Popup

Dec 26th, 2019
45
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #auto-remove-sublime-license-popup
  2. #Copy the script
  3. #In ST3, open "Tools --> Developer --> New Plugin ...."
  4. #Paste the script in the new file created.
  5. #Save changes. Put ANY name just adding ".py" extension.
  6. ----------------------------------------------------------------------------------------------------------------
  7. #!/usr/bin/python
  8. # -*- coding: utf-8 -*-
  9.  
  10. import sublime_plugin
  11. import subprocess
  12. from time import sleep
  13. import sys
  14.  
  15. cl = lambda line: subprocess.Popen(line, shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
  16. log = lambda message: sys.stderr.write("Log: %s\n" % message)
  17.  
  18. sublimeMainWindowTitle = " - Sublime Text (UNREGISTERED)"
  19.  
  20. class LicenseWindowKiller(sublime_plugin.EventListener):
  21.  
  22.     def seek_n_close(self):
  23.         sublimePid = int(cl("""wmctrl -lp | grep "%s" | awk '{print $3}'""" % sublimeMainWindowTitle).decode())
  24.         if sublimePid:
  25.             sublimeMainWindowId = cl("""wmctrl -lp | grep "%s" | awk '{print $1}'""" % sublimeMainWindowTitle).decode()
  26.             sublimeSecondWindowId = cl("""wmctrl -lp | grep %s | awk '{ids[$1]++}{for (id in ids){if (id != "%s"){printf id}}}'""" % (sublimePid, sublimeMainWindowId)).decode()
  27.             if sublimeSecondWindowId:
  28.                 sublimeSecondWindowTitle = cl("""wmctrl -lp | grep %s | awk '{print $5}'""" % sublimeSecondWindowId).decode()
  29.                 if not sublimeSecondWindowTitle:
  30.                     cl("wmctrl -i -c %s" % sublimeSecondWindowId)
  31.                     return True
  32.         return False
  33.  
  34.     def on_pre_save_async(self, *args):
  35.         seek = True
  36.         counter = 10
  37.         while seek:
  38.             sleep(.5)
  39.             counter -= 1
  40.             if counter < 0:
  41.                 seek = False
  42.             seek = not self.seek_n_close()
  43. ----------------------------------------------------------------------------------------------------------------
  44. # Place this file in ~/.config/sublime-text-3/Packages/User/
  45. import sublime
  46. import sublime_plugin
  47.  
  48. import subprocess
  49. from time import sleep
  50. import sys
  51.  
  52. cl = lambda line: subprocess.Popen(line, shell=True, stdout=subprocess.PIPE).communicate()[0].strip()
  53. log = lambda message: sys.stderr.write("Log: %s\n" % message)
  54.  
  55.  
  56. class LicenseWindowKiller(sublime_plugin.EventListener):
  57.     def run(self, edit):
  58.         pass
  59.  
  60.     def seek_n_close(self):
  61.         # Get main winids and pid
  62.         out = cl("""wmctrl -Gpl | grep "Sublime Text (UNREGISTERED)" | awk '{print $1, $3}'""").splitlines()
  63.         out = [c.strip() for c in out]
  64.         for c in out:
  65.             win_id, pid = c.split()
  66.             pid = int(pid)
  67.             out_2 = cl("""wmctrl -Gpl | grep '{}' | grep -v '{}'  | awk '{{print $1, $6, $7}}'""".format(pid, win_id)).decode().splitlines()
  68.             for c_2 in out_2:
  69.                 w2_id, w, h = c_2.split()
  70.                 w, h = int(w), int(h)
  71.                 if (w, h) == (541, 179):
  72.                     title = cl("""wmctrl -lp | grep {}| awk '{{print $5}}'""".format(w2_id)).decode()
  73.                     if not title:
  74.                         cl("wmctrl -i -c {}".format(w2_id))
  75.                         return True
  76.         return False
  77.  
  78.     def on_pre_save_async(self, *args):
  79.         seek = True
  80.         counter = 10
  81.         while seek:
  82.             sleep(.5)
  83.             counter -= 1
  84.             if counter < 0:
  85.                 seek = False
  86.             seek = not self.seek_n_close()
RAW Paste Data