Exiting API to interact with Atom from an external process?


I want to find out what project is open in the last active Atom window from an external script so I can use the project configuration in Alfred workflows (things like "open the docs for this package for the version the current project is using, etc.).

Is there an existing way to interact with Atom from external processes?

If not, I can think of two approaches off the top of my head:

  1. Write a package that boots up a simple HTTP or socket server in Atom and interact through that. To start it could basically just eval strings and return the JSON of the results or something.

  2. Write a package that finds a way to hook into window focus and write the path to some known location.

Not sure of the feasibility of either, comments and suggestions welcome.



Sockets sounds like the way to go. Atom packages can do anything that you can come up with using Node modules.