nate-parrott/Flashlight — pull request #95 by ZeR0-Wu (2014-11-22 13:40:31+00:00)
Title: Fix a naming conflict bug causing Flashlight and other SIMBL like EasySIMBL can not work together

Today I found my EasySIMBL plugin (https://github.com/ZeR0-Wu/FinderTweak) not work and after all day work around the source code between Flashlight and EasySIMBL I notice there is a bug in Flashlight.

##Reproduce the problem:

1. install EasySIMBL and a plugin like [`FinderTweak`](https://github.com/ZeR0-Wu/FinderTweak)
2. install Flashlight and enable it (may be you need install a Flashlight plugin)
3. relaunch EasySIMBL plugin powered App, in my case, Finder.app
4. the plugin won't work any more
5. try to reinstall EasySIMBL and re-enable EasySIMBL won't help

The solution is to remove `~/Library/ScriptingAdditions/Flashlight.osax`, then relaunch Finder.app, all things works normally.

##Explaination:

SIMBL agents actually doesn't not inject anything into an app, in just send an customized Apple Event to an app. Since the event is unknown, this app will try to find an outside handler to handle this event and thus load corresponding `osax` file in `ScriptingAdditions` folder. The `Flashlight.osax` file has all the content from SIMBL.m, and when it become part of app's process, it check and install the plugins from disk.

So where's the conflict?

`Flashlight.osax` and `EasySIMBL` are using the same customized AppleEvent `ESIM`(stand for "EasySIMBL") and id `load` . So there are two `osax` file in `ScriptingAdditions` folder both declared as handler for event `ESIMload`. When EasySIMBL's agent "inject" an app (just send event by `[sbApp sendEvent:'ESIM' id:'load' parameters:0];`), this app load `Flashlight.osax` instead and thus end up finding in Flashlight's plugin folder, where nothing there to be loaded. Since the mechanism is data-driven, conflict will not show until the app is "injected" again.

In my case other app always load `Flashlight.osax`, but things may also reverse. Remove one `osax` file may temporarily fix the problem.

##Fix
Just make Flashlight using its own Apple Event.