Skip to content

RFC: Command Hooks #10

@justincampbell

Description

@justincampbell

It would be nice to be able to associate any functionality you wanted when a pomodoro was started/completed, and we could accomplish that through hooks which execute shell commands.

Commands

There are a few commands where this makes sense:

  • Starting
    • start - Start a new Pomodoro
    • repeat - Repeat the last Pomodoro
  • Stopping
    • finish - Finish the current Pomodoro
    • cancel - Cancel the current Pomodoro
    • break - Take a break

start

Start is fairly straightforward, as it would exec the given command when the start command is passed.

repeat

Repeat would function the same way as start (it also delegates to start internally).

finish

Finish is a command which modifies the duration of the pomodoro to be now - start_time, effectively changing the end time to now. Typically I use it to finish a pomodoro early or late. Most of the time I never use this command, and instead just see that the pomodoro has ended and go take a break.

Adding a hook to finish would either require either A) the user to use the finish command or B) a daemon which watches for pomodoros finishing and then runs commands.

I would not like to do B, because on top of adding a lot more complexity to run the manage the background process, there could also be running in a different environment, which would make some exec commands fail unexpectedly. But I'm not opposed to it.

cancel

Cancel effectively undos the last pomodoro. I think this should run the same hook as finish.

break

I think it makes sense to merge finish and break together, since they are both things you do at the end of the pomodoro. At the very least, finish should have a --break flag which defaults to true or 5m (#7).

Hooks

We could introduce 2 hook settings, representing a start or finish/end:

start_hook="say starting"
end_hook="say done"

Multiple hooks

It should be possible to declare multiple hooks for the same event:

start_hook=slack -dnd 25m
start_hook=~/dnd.sh on
end_hook=~/dnd.sh off

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions