when-command
when-command copied to clipboard
Pass data to tasks
Apart from plain time-based events, most events (and thus satisfied conditions) carry important or at least interesting information that could be exploited by tasks to modify their behavior. There should be the option to access this data for commands that are run by tasks. The most likely implementation is an environment variable, let's call it WHEN_COMMAND_DATA
, that carries a documented, JSON-formatted aggregate containing all data that comes with the event. It's then up to the user to interpret such data with appropriate tools, such as jq or similar utilities. Data is differently structured in different events, so the relatively free (and relatively standard) JSON form is probably the best option.
The implementation should not modify the internal format of the main When objects to avoid compatibility breaks.
A problem can occur when multiple events trigger the same task set: since in that case further occurrences of the same event are discarded, some data could be lost.
More related to whenever than to when at the moment: closing it.