diff options
-rwxr-xr-x | tw_hooks/on-add_scheduled_work_task.pl | 10 | ||||
-rw-r--r-- | tw_hooks/tw_scheduled_task_remind | 17 |
2 files changed, 26 insertions, 1 deletions
diff --git a/tw_hooks/on-add_scheduled_work_task.pl b/tw_hooks/on-add_scheduled_work_task.pl index 296066f..6593e12 100755 --- a/tw_hooks/on-add_scheduled_work_task.pl +++ b/tw_hooks/on-add_scheduled_work_task.pl @@ -25,6 +25,12 @@ my $added_task = <STDIN>; my $work_rem_file = '~/.reminders/work.rem'; my $decoded_task = decode_json $added_task; my $original_description = ${$decoded_task}{description}; +my $lead_time; +my $lead_regex = qr/%\:(\d+)/; +if (($original_description =~ m/$lead_regex/g)) { + $lead_time = $1; + $original_description =~ s/$lead_regex//g; +}; my $tags = ${$decoded_task}{tags}; # alternative - not using -> in the ref my $scheduled_dt; @@ -37,7 +43,7 @@ if ($decoded_task->{scheduled} and (scalar grep {$_ eq "dft" } @{$tags})) { my $min = $scheduled_dt->minute(); my $time = $scheduled_dt->hms(); # Convert it into Remind format - my $remind_line = "REM $date $month $year AT $time MSG $original_description \%b\n"; + my $remind_line = "REM $date $month $year AT $time +$lead_time MSG $original_description\%b\n"; # Log into remote server @@ -64,6 +70,8 @@ if ($decoded_task->{scheduled} and (scalar grep {$_ eq "dft" } @{$tags})) { Contents of $work_rem_file on $host is now:\n/, @out_file; + # TODO - we need to strip away the %:MIN syntax from the original + # description - need to substitute it here! print encode_json $decoded_task; exit 0; } else { diff --git a/tw_hooks/tw_scheduled_task_remind b/tw_hooks/tw_scheduled_task_remind new file mode 100644 index 0000000..e08b855 --- /dev/null +++ b/tw_hooks/tw_scheduled_task_remind @@ -0,0 +1,17 @@ +.\" Manpage for tw_scheduled_remind +.\" Contact y@yulqen.org to correct errors or typos. +.TH man 7 "24 November 2020" "1.0" "tw_scheduled_remind man page" +.SH NAME +tw_scheduled_remind \- create Remind event upon adding new Taskwarrior task with schedule set +.SH SYNOPSIS +task add "Task name [%:10]" schedule:2020-10-10 +dft +.SH DESCRIPTION +tw_scheduled_remind is a hook for Taskwarrior written in Perl. It's sets a new Remind event for the task, given a suitable "schedule" attribute. +.SH OPTIONS +None. +.SH SEE ALSO +task(5), taskrc(5) +.SH BUGS +Plenty of them. +.SH AUTHOR +Matthew Lemon (y@yulqen.org) |