From 2a3bea6fcc6df013c06bc29805747db0e6763108 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Fri, 16 Dec 2022 06:53:18 +0000 Subject: cleanup before migration --- annex_discovery.pl | 14 ++++++++++++++ calendar/dayplan_revised.pl | 2 +- calendar/modevent.pl | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 annex_discovery.pl diff --git a/annex_discovery.pl b/annex_discovery.pl new file mode 100644 index 0000000..b645dc6 --- /dev/null +++ b/annex_discovery.pl @@ -0,0 +1,14 @@ +#!/usr/bin/env perl + +use strict; +use warnings; +use feature q(say); + +open my $fh, "<", "/home/lemon/Documents/find_these_paths.txt" or die "Cannot open file"; +while (<$fh>) { + if ($_ =~ q[^/home/lemon/annex/(.*) \(1 copy\)]) { + my $path = quotemeta($1); + my $out = `git annex whereis $path`; + say $out; + } +} diff --git a/calendar/dayplan_revised.pl b/calendar/dayplan_revised.pl index 43e74a7..bf72ea7 100755 --- a/calendar/dayplan_revised.pl +++ b/calendar/dayplan_revised.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl # Porting dayplan.ksh to Perl use strict; diff --git a/calendar/modevent.pl b/calendar/modevent.pl index 38f1e02..bffb972 100755 --- a/calendar/modevent.pl +++ b/calendar/modevent.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use warnings; use strict; -- cgit v1.2.3 From 680216be8bcb4cf13f1621f1f0459c771fdda814 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Sat, 25 Mar 2023 17:07:07 +0000 Subject: some tweaks for nix and dayplan --- calendar/dayplan.pl | 6 +++++- calendar/dayplan_revised.pl | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/calendar/dayplan.pl b/calendar/dayplan.pl index 3074c2d..3de906a 100755 --- a/calendar/dayplan.pl +++ b/calendar/dayplan.pl @@ -59,7 +59,7 @@ sub schoollines { return " 08:15 - 08:20 - Harvey to school 08:45 - 09:00 - Sophie to school -09:15 - 09:30 - Email"; +"; } } @@ -88,6 +88,10 @@ Reminders: --------- $reminders $s +Implementation Intentions: + +- I will X at HH:MM. + 09:30 - 10:00 - 10:00 - 11:00 - 11:00 - 12:00 - diff --git a/calendar/dayplan_revised.pl b/calendar/dayplan_revised.pl index bf72ea7..53be0b1 100755 --- a/calendar/dayplan_revised.pl +++ b/calendar/dayplan_revised.pl @@ -1,4 +1,4 @@ -#!/usr/bin/env perl +#!/usr/bin/env -S perl # Porting dayplan.ksh to Perl use strict; @@ -6,7 +6,7 @@ use warnings; use DateTime; use JSON; -my $dayplans = '/home/lemon/Notes/journal/day_plans'; +my $dayplans = '/home/lemon/Documents/Notes/journal/day_plans'; #my $dayplans = "/tmp/dayplans"; sub parse_args { -- cgit v1.2.3 From f11b2bdd214c74b7a2aedb0516a22db25e95a2c3 Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Tue, 25 Apr 2023 13:45:47 +0100 Subject: added file --- rename-journal-files.pl | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 rename-journal-files.pl diff --git a/rename-journal-files.pl b/rename-journal-files.pl new file mode 100644 index 0000000..24dc712 --- /dev/null +++ b/rename-journal-files.pl @@ -0,0 +1,13 @@ +#!/usr/bin/env perl + +opendir(DIR, ".") || die "Can't open directory: $!\n"; + +while (my $file = readdir(DIR)) { + if ($file =~ /(\d{4})_(\d{2})_(\d{2})\.md$/) { + my $new_name = "$1-$2-$3.md"; + rename($file, $new_name) || die "Can't rename file '$file': $!\n"; + } +} + +closedir(DIR); + -- cgit v1.2.3 From 34af3f14728ef5a3565cd2f6fec46d6bf9c3a20f Mon Sep 17 00:00:00 2001 From: Matthew Lemon Date: Wed, 3 May 2023 07:25:17 +0100 Subject: Adds perl script to send taskwarrior output to an email address --- task_report_to_email.pl | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100755 task_report_to_email.pl diff --git a/task_report_to_email.pl b/task_report_to_email.pl new file mode 100755 index 0000000..f1260ed --- /dev/null +++ b/task_report_to_email.pl @@ -0,0 +1,56 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use JSON; +use DateTime::Format::ISO8601; +use IPC::Open2; + +# written in collaboration with GPT-4 on 2023-05-03. +# This script takes the output of the taskwarrior filter on line 11 and sends it to the email +# address provided in the first command line argument, using neomutt, which obviously must be +# configured. There is probably more that can be done to format it correctly. Obviously, the two +# perl modules above are required. + +# Check if the recipient email address is provided +if (@ARGV < 1) { + print "Usage: $0 recipient_email\n"; + exit 1; +} + +my $recipient_email = $ARGV[0]; + +# Execute Taskwarrior command +my $task_cmd = "task status:pending project:w export"; +# my $task_cmd = "task status:pending limit:page -idea -killlist project.not:h.buy export"; +my $task_output; +open(my $task_fh, "-|", $task_cmd) or die "Can't execute Taskwarrior command: $!"; +{ + local $/ = undef; + $task_output = <$task_fh>; +} +close($task_fh); + +# Process Taskwarrior output +my $tasks = decode_json($task_output); +my @sorted_tasks = sort { ($a->{scheduled} // "9999") cmp ($b->{scheduled} // "9999") } @$tasks; + +# Compose email content +my $email_content = "Subject: Task Report\n\n"; +for my $task (@sorted_tasks) { + $email_content .= sprintf "%s - %s%s%s%s\n", + $task->{description}, + $task->{project} // "-", + $task->{scheduled} ? " - Scheduled: " . DateTime::Format::ISO8601->parse_datetime($task->{scheduled})->strftime("%Y-%m-%d %H:%M") : "", + $task->{due} ? " - Due: " . DateTime::Format::ISO8601->parse_datetime($task->{due})->strftime("%Y-%m-%d %H:%M") : "", + $task->{priority} ? " - Priority: " . $task->{priority} : ""; +} + +# Send email using Neomutt +my $neomutt_cmd = "neomutt -s \"Task Report\" $recipient_email"; +my ($neomutt_in, $neomutt_out); +my $neomutt_pid = open2($neomutt_out, $neomutt_in, $neomutt_cmd) or die "Can't execute Neomutt command: $!"; +print $neomutt_in $email_content; +close($neomutt_in); +waitpid($neomutt_pid, 0); + -- cgit v1.2.3