Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Auto-remove Sublime's license popup
#!/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()
@VMBindraban

This comment has been minimized.

Copy link

VMBindraban commented Mar 10, 2015

ValueError: invalid literal for int() with base 10: ''
Writing file filename.js with encoding UTF-8 (atomic)
Traceback (most recent call last):
  File "/opt/sublime_text/sublime_plugin.py", line 247, in on_pre_save_async
    callback.on_pre_save_async(v)
  File "/home/vijay/.config/sublime-text-3/Packages/own/windowKiller.py", line 36, in on_pre_save_async
    seek = not self.seek_n_close()
  File "/home/vijay/.config/sublime-text-3/Packages/own/windowKiller.py", line 17, in seek_n_close
    sublimePid = int(cl("""wmctrl -lp | grep "%s" | awk '{print $3}'""" % sublimeMainWindowTitle).decode())
ValueError: invalid literal for int() with base 10: ''

Seems your plugin doesn't work anymore.

@iwglobal

This comment has been minimized.

Copy link

iwglobal commented Mar 6, 2016

Hi Where can I put this code into?

@cchaldo

This comment has been minimized.

Copy link

cchaldo commented Apr 5, 2016

how do we run this? which directory should it be in ?

@elliott-beach

This comment has been minimized.

Copy link

elliott-beach commented Jan 11, 2017

This is a sublime plugin ( you can tell by the import sublime_plugin statement) . See http://stackoverflow.com/questions/15652758/how-to-install-plugins-to-sublime-text-2-editor

@functionOverlord

This comment has been minimized.

Copy link

functionOverlord commented Feb 6, 2017

Works like a charm. It removes the most frequently appearing pop-up of the two "unregistered" reminders, the one remaining is not an issue due to it's infrequency.

Just download, unzip, and move to "sublime folder\Data\Packages".

@vivekpatani

This comment has been minimized.

Copy link

vivekpatani commented Feb 26, 2017

Is this applicable for Sublime Text 3, if yes could you please explain?

@somendra007

This comment has been minimized.

Copy link

somendra007 commented May 3, 2017

please tell me where can I put this code in sublime?

@KeyC0de

This comment has been minimized.

Copy link

KeyC0de commented Jun 17, 2017

Does not work with Sublime Text 3 on Ubuntu 16.04 LTS.

Or instructions were not clear. Oh right.. there are none..

He spent so much time to write a program, but not 10 seconds to write a sentence describing its installation...

I just downloaded the zip and placed in Packages folder the unzipped folder. Restarted Sublime, but the message is still popping up.

@hippybear

This comment has been minimized.

Copy link

hippybear commented Jul 1, 2017

@CobraL0rd that's because those of us who know how to code, don't need a walkthrough tutorial on how to install Sublime plugins, those who don't know how to code, should at the very LEAST know how to google "How to install Sublime Text plugins"

@danjambur

This comment has been minimized.

Copy link

danjambur commented Jul 19, 2017

@hippybear with that logic, nothing should ever be documented, because I should always be able to google the documentation. You're alienating members of the community by replying condescendingly, and I agree with @CobraL0rd, it should be documented.

Oh, and BTW; I know how to 'code' (whatever that means), yet I still can't figure out how to run this. So again, your logic is faulted, and it's rude to talk down to members of the community as if they are idiots, just because you can do something; and they can't. I'd suggest you stop painting with such a broad brush, and instead maybe offer a step in the right direction, instead of talking them down.

@zogorn

This comment has been minimized.

Copy link

zogorn commented Jul 29, 2017

@hippybear so you can help the community and commit the documentation.
and yes the plugin needs a documentation.

@JackDinn

This comment has been minimized.

Copy link

JackDinn commented Aug 13, 2017

Well iv spent a couple of days on this one but even though your all going to call me a noob I don't care. I could not figure how to install this.

Did exactly this :-

Just download, unzip, and move to "sublime folder\Data\Packages".

And read all the links provided above. But im still getting the pop-up.

Thanks though.

@cardaba

This comment has been minimized.

Copy link

cardaba commented Sep 15, 2017

It's a very simple procedure:

  1. Copy the script
  2. In ST3, open "Tools --> Developer --> New Plugin ...."
  3. Paste the script in the new file created.
  4. Save changes. Put ANY name just adding ".py" extension.
    You're done.
    You can check in the console if the plugin has been loaded by ST3 using the console. For example I used "killer.py" and you can see in the console:
    reloading plugin User.killer
@AdityaAnand1

This comment has been minimized.

Copy link

AdityaAnand1 commented Oct 14, 2017

Does not seem to work with the latest sublime (Build 3143)

@cardaba I followed your steps, even got the reloading plugin User.killer message in the console, but nothing seems to change. I still get the prompts every now and then.

If anyone knows of a solution, please share! The annoying pop up completely breaks my flow every single time.

@markprovan-itison

This comment has been minimized.

Copy link

markprovan-itison commented Oct 23, 2017

@AdityaAnand1 Maybe buy the software?

@korbnep

This comment has been minimized.

Copy link

korbnep commented Nov 1, 2017

It's working with build 3143 on Debian 9, but the nag message isn't the only popup being killed. The "close without saving" dialog is nixed very quickly as well.

@Graviton48

This comment has been minimized.

Copy link

Graviton48 commented Jan 25, 2018

Um...finally how do I get this to work with the latest sublime??

@Graviton48

This comment has been minimized.

Copy link

Graviton48 commented Jan 25, 2018

Any ideas anybody...Pls help, or let me know about another good code editor

@f4th4n

This comment has been minimized.

Copy link

f4th4n commented Jan 27, 2018

replace
sublimeMainWindowTitle = " - Sublime Text (UNREGISTERED)"
with
sublimeMainWindowTitle = " - Sublime Text"

if your sublime has been registered

@ramGyawali

This comment has been minimized.

Copy link

ramGyawali commented Feb 1, 2018

Just click Ctrl + ` in sublime and paste the above codes and hit 'Enter'.Everything will work just fine.By the way,thank you for the code @egel

@solraves

This comment has been minimized.

Copy link

solraves commented Feb 9, 2018

It worked for build 3143 when I removed the "UNREGISTERED"

@michael13491

This comment has been minimized.

Copy link

michael13491 commented Mar 7, 2018

Followed carbada's comment, but was getting "invalid literal for int() with base 10" error message in sublime console when the plugin is loaded.

I fixed the issue by installing wmctrl package on my machine.

On ubuntu install the package with "sudo apt-get install wmctrl"

@tamimibrahim17

This comment has been minimized.

Copy link

tamimibrahim17 commented Apr 30, 2018

any solution for windows ?

@ghost

This comment has been minimized.

Copy link

ghost commented May 2, 2018

Instructions unclear.
Have my finger stuck in USB female adaptor.

@tranghaviet

This comment has been minimized.

Copy link

tranghaviet commented May 3, 2018

add 127.0.0.1 license.sublimehq.com to your hosts file.

@Un1Gfn

This comment has been minimized.

Copy link

Un1Gfn commented May 10, 2018

@VMBindraban @michael13491 (ArchLinux) wmctrl works and no error. Many a thanks.

@ajsnyde

This comment has been minimized.

Copy link

ajsnyde commented May 16, 2018

Not working for me. Windows 10, running unregistered. Created plugin as per directions from cardaba.

@crimsonsoccer55

This comment has been minimized.

Copy link

crimsonsoccer55 commented May 25, 2018

Can't get it either

@mazzarito

This comment has been minimized.

Copy link

mazzarito commented May 26, 2018

This is only going to work on linux .. wmctrl doesn't exist on windows

@costabatista

This comment has been minimized.

Copy link

costabatista commented Aug 6, 2018

It worked fine to me. Thanks. (Sublime 3)

@sharegrams

This comment has been minimized.

Copy link

sharegrams commented Aug 16, 2018

Thank you, Egel!

This crap was so obnoxious. Especially if you have tons of files open and you have some scripts that are modifying the textfiles in the background. Meaning it's doing tons of counts on the incremental counter in the BG.

Made it unusable and frustrating.

@passooo

This comment has been minimized.

Copy link

passooo commented Sep 6, 2018

Awesome, it works on my laptop running Darwin.

@mrParabol

This comment has been minimized.

Copy link

mrParabol commented Sep 28, 2018

It's a very simple procedure:

  1. Copy the script
  2. In ST3, open "Tools --> Developer --> New Plugin ...."
  3. Paste the script in the new file created.
  4. Save changes. Put ANY name just adding ".py" extension.
    You're done.
    You can check in the console if the plugin has been loaded by ST3 using the console. For example I used "killer.py" and you can see in the console:
    reloading plugin User.killer

killer.py is incorrect when typing, but the response is correct.

>>>import sublime_plugin
>>> sublime_plugin.reload_plugin('User.killer')
console output:
reloading plugin User.killer

@reallyquickturtle

This comment has been minimized.

Copy link

reallyquickturtle commented Oct 10, 2018

Has anyone gotten this to work on macOS? I've installed wmctrl using brew but I'm still getting ValueError: invalid literal for int() with base 10: ''

@ReverseSpidey

This comment has been minimized.

Copy link

ReverseSpidey commented Nov 30, 2018

Excelente! Muchas gracias.

@shamiul94

This comment has been minimized.

Copy link

shamiul94 commented Jan 26, 2019

It works like magic dude.

@CSharpFiasco

This comment has been minimized.

Copy link

CSharpFiasco commented Feb 24, 2019

For anyone trying to make this work, it looks like this will only work on Linux machines, not windows. What this program seems to be doing is running commands to try to get Process Ids (based off the window name) to determine which window to close. Of course those commands are going to be sensitive to the operating system. If you're using Linux, you'll probably need to install wmctrl.

If you're getting the error ValueError: invalid literal for int() with base 10: '', this is probably why.

Instructions by mrParabol should work if you meet the system requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.