sheagcraig / yo

Send Notification Center messages from the command line
Apache License 2.0
383 stars 44 forks source link

[feature][RFC] Add support for multiple actions #45

Open mullender opened 5 years ago

mullender commented 5 years ago

Looking for feedback on the following, I am considering creating a PR to add the capability of having multiple actions in a notification. Similar to what is described in this blog: https://blog.gaelfoppolo.com/user-notifications-in-macos-66c25ed5c692

Feature

Initially I would like to support having different actions for clicking the main content area (ContentsClicked), and clicking the action button (ActionButtonClicked). For example: clicking the main area would direct to more information, and clicking the action button would apply a change.

Ultimately it would be nice to also support the dropdown actions (AdditionalActionClicked)

Implementation

First, it is essential to keep the command line API backwards compatible. e.g. currently clicking the main area of this notification opens example.com, but does not dismiss the notification: yo_scheduler -t "Hi" -a "http://example.com" We do not want to break that.

main content actions

For adding an action for the main content I propose adding these command line options:

-ca, --content-action-path
-cB, --content-bash-action

if specified these would be executed when clicking the main content of the notification (and close the notification?), any actions specified for the action button would not apply to the main content in this case. e.g.: yo_scheduler -t "Example 1" -ca "http://example.com/1" -b "example 2" -a "http://example.com/2"

Specifying -ca and -a but not -b would be an error.

additional action buttons

I think the best api for this might be to allow repeated action button flags: yo_scheduler -t "Example 1" -ca "http://example.com/1" -b "example 2" -a "http://example.com/2" -b "example 3" -a "http://example.com/3" -b "example 4" -a "http://example.com/4" -b "example 5" -B "say 'I hope you enjoyed exampl5\!'"

erikng commented 5 years ago

I like this idea but only concern is if an admin does this as root, there will be a potentially long tailed root process waiting for user to click the notification that might be able to be abused.

Perhaps this feature can only be scheduled as the user to limit its destruction? Only issue is if people are trying to do actions that require root, it wouldn't work.

mullender commented 5 years ago

@erikng I am not sure I understand the concern, and how it differs from the current situation. What types of 'destruction' does this feature add, that are not already possible today?

If we schedule a notification with a dangerous bash command, that would be as bad today as it would be after this lands. Or perhaps I am not understanding it correctly.