Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a program to register for notification of context change #55

Closed
dustinrue opened this issue Oct 3, 2011 · 11 comments
Closed

Allow a program to register for notification of context change #55

dustinrue opened this issue Oct 3, 2011 · 11 comments
Assignees
Milestone

Comments

@dustinrue
Copy link
Owner

Create a protocol for how a third party app can register for context change notifications. The target app should be able to tell CP that it wishes to be notified of changes and how it should be called. Two methods should be supported including a call to an external binary or via AppleScript. CP should call the external app or use AppleScript with a single argument, the current context.

@djbe
Copy link
Collaborator

djbe commented Oct 3, 2011

Say hello to NSDistributedNotificationCenter. No need for special registration functions or anything of the like, just post a certain notification to this class/instance/whatever and any registered app receives it.

@dustinrue
Copy link
Owner Author

Looks great for apps that are running but what about non-running apps. Would it behave like scripting bridge/apple script and start the app? Nice find BTW.

On Oct 3, 2011, at 7:37 AM, David Jennes wrote:

Say hello to NSDistributedNotificationCenter. No need for special registration functions or anything of the like, just post a certain notification to this class/instance/whatever and any registered app receives it.

Reply to this email directly or view it on GitHub:
#55 (comment)

@djbe
Copy link
Collaborator

djbe commented Oct 3, 2011

What I gathered from your description of the issue was that the app was already running. If it isn't, a simple openAction or shellScriptAction would do it, right?

@dustinrue
Copy link
Owner Author

I'd like either to work. If the app that registers has some sort of helper app, like Time Machine's backupd-helper for example, then the app should be able to register that helper app as the app that needs the notification.

On Oct 3, 2011, at 8:32 AM, David Jennes wrote:

What I gathered from your description of the issue was that the app was already running. If it isn't, a simple openAction or shellScriptAction would do it, right?

Reply to this email directly or view it on GitHub:
#55 (comment)

@djbe
Copy link
Collaborator

djbe commented Oct 3, 2011

Not sure I follow, mind explaining the situation a bit more?

@dustinrue
Copy link
Owner Author

Sure.

Let's say an app wants to be notified of a context change from ControlPlane so it registers with CP. There are then two ways CP can issue the notification:

  1. It can use AppleScript. This would be good for apps that are always running and or running in the background.
  2. It can call a command line tool. An example of this is if I create an app for managing Time Machine backup destinations I want to provide a command line tool that allows it to switch backup destinations without launching the full app. The command line tool could simply be switchTMBackup which would carry out the work.

I could just as easily call an external app but I was thinking of creating something that required a bit less thought and work to implement for the CP user.

On Oct 3, 2011, at 8:32 AM, David Jennes wrote:

What I gathered from your description of the issue was that the app was already running. If it isn't, a simple openAction or shellScriptAction would do it, right?

Reply to this email directly or view it on GitHub:
#55 (comment)

@djbe
Copy link
Collaborator

djbe commented Oct 3, 2011

What about:
your app is just a front-end (GUI) for a daemon, and this daemon registers with CP using the distributed notification center. Obviously the daemon is part of the app, just not directly visible to the user.

On 03 Oct 2011, at 15:57, Dustin Rue wrote:

Sure.

Let's say an app wants to be notified of a context change from ControlPlane so it registers with CP. There are then two ways CP can issue the notification:

  1. It can use AppleScript. This would be good for apps that are always running and or running in the background.
  2. It can call a command line tool. An example of this is if I create an app for managing Time Machine backup destinations I want to provide a command line tool that allows it to switch backup destinations without launching the full app. The command line tool could simply be switchTMBackup which would carry out the work.

I could just as easily call an external app but I was thinking of creating something that required a bit less thought and work to implement for the CP user.

On Oct 3, 2011, at 8:32 AM, David Jennes wrote:

What I gathered from your description of the issue was that the app was already running. If it isn't, a simple openAction or shellScriptAction would do it, right?

Reply to this email directly or view it on GitHub:
#55 (comment)

Reply to this email directly or view it on GitHub:
#55 (comment)

@dustinrue
Copy link
Owner Author

While it makes sense, I'd also like to avoid more system services running.
On Oct 3, 2011, at 8:32 AM, David Jennes wrote:

What I gathered from your description of the issue was that the app was already running. If it isn't, a simple openAction or shellScriptAction would do it, right?

Reply to this email directly or view it on GitHub:
#55 (comment)

@djbe
Copy link
Collaborator

djbe commented Oct 3, 2011

In this case, just look at the complexity difference between the method you propose and mine:
Registration (yours):

  • Apps register with CP through the DNC
  • CP keeps a list of registered apps
  • On context change, CP goes through list and calls apps
    DNC (mine):
  • Apps/daemons register with DNC
  • CP calls DNC on context change

My proposal is essentially 2 or 3 method calls and quite simple/clean, while the registration way of working brings along all the trouble of keeping track of all registrars. Why re-invent the wheel when the DNC does everything for us?

On 03 Oct 2011, at 16:05, Dustin Rue wrote:

While it makes sense, I'd also like to avoid more system services running.
On Oct 3, 2011, at 8:32 AM, David Jennes wrote:

What I gathered from your description of the issue was that the app was already running. If it isn't, a simple openAction or shellScriptAction would do it, right?

Reply to this email directly or view it on GitHub:
#55 (comment)

Reply to this email directly or view it on GitHub:
#55 (comment)

@dustinrue
Copy link
Owner Author

"rejected" for 1.x.x series, lets put this is 2.x.x at some point

@ghost ghost assigned djbe Nov 3, 2011
@spacex
Copy link

spacex commented Nov 16, 2011

I would like to suggest that this use the distributed notification center or already running apps. If an app needs to be started, it would make sense for it to be kicked off as an action. Is there a specific use-case that you had in mind that would need the notification of context change to notify if the app is already running and start it if it isn't?

Fwiw, distributed notification center is how i was able to implement an action that would change synergy configurations depending on context, working with SynergyKM to store and change the configurations, while CP would have it change.

djbe pushed a commit that referenced this issue Feb 16, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants