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

Support hooks #564

Open
boyska opened this issue Oct 18, 2023 · 3 comments
Open

Support hooks #564

boyska opened this issue Oct 18, 2023 · 3 comments
Labels
discussion Discussion on a topic enhancement New feature or request

Comments

@boyska
Copy link

boyska commented Oct 18, 2023

I'd like to run a command every time I start/stop a new activity.

I would be ok with a simple command being invoked with no argument: I will then look at timew get to discover the current status and behave accordingly.

@lauft lauft added enhancement New feature or request discussion Discussion on a topic labels Oct 20, 2023
@lauft
Copy link
Member

lauft commented Oct 20, 2023

I would not tie the hook to the start/stop command explicitly, e.g. what about when you start a new tracking with continue? Therefore, I would rather react on certain events than commands.

Drawing inspiration from Taskwarrior, which has defined the following events to trigger appropriate hooks:

  • on-launch, triggered once, after initialization, before any processing occurs
  • on-exit, triggered once, after all processing is complete
  • on-add, triggered separately for each task added
  • on-modify, triggered separately for each task added or modified

Your case would match the on-add or the on-exit event here.

Some further thoughts:

  • Adding a hooks API should be done with extensibility in mind. Using JSON as communication format seems useful. This way, one can convey meta information easily to the hook, e.g. which command has been called, etc.
  • One should start simple, e.g. with the on-exit event, which would call any hook with a payload like this:
    {"command":"<command>"}
    
  • From there, further hook points can be defined/their payload refined.

For reference, issue #49 also requests a way to control Taskwarrior when stopping time tracking

@boyska
Copy link
Author

boyska commented Oct 20, 2023

I would not tie the hook to the start/stop command explicitly, e.g. what about when you start a new tracking with continue? Therefore, I would rather react on certain events than commands.

totally makes sense!

One should start simple, e.g. with the on-exit event, which would call any hook with a payload like this:

that would totally be enough for my specific usecase, and I agree it makes sense to start simple.

@Spreadcat
Copy link

Yes, I came up with that requirement today as well. In my case I'd like to trigger my local bluetooth service and power it on and off base on the tag I work with. There are also other scenarios that would be useful for me personally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Discussion on a topic enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants