diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2013-01-13 15:37:49 -0200 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2013-01-13 15:37:49 -0200 |
commit | 454c6e3c77b3db507ee81875219089047fc2d5a3 (patch) | |
tree | 34ea351902ddd6094bc0a96a65b4bc07e9ee83d8 /misc/parse_remind.pl | |
download | scripts-454c6e3c77b3db507ee81875219089047fc2d5a3.tar.gz scripts-454c6e3c77b3db507ee81875219089047fc2d5a3.tar.bz2 |
Initial import
Diffstat (limited to 'misc/parse_remind.pl')
-rw-r--r-- | misc/parse_remind.pl | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/misc/parse_remind.pl b/misc/parse_remind.pl new file mode 100644 index 0000000..bdd9f23 --- /dev/null +++ b/misc/parse_remind.pl @@ -0,0 +1,41 @@ +#!/usr/bin/perl +# +# This script is designed to have an email piped to it eg. from mutt. +# It will split apart all the text/calendar attachments and enter them into +# the 'remind' calendar. +# + +use strict; +use warnings; + +use MIME::Parser; + +my $CONVERT = '~/.mutt/ical2rem.pl'; +my $REMINDERS = '~/remind/mutt.rem'; + +################################################################################ + +my $parser = new MIME::Parser; +$parser->output_under('/tmp'); +my $entity = $parser->parse(\*STDIN); + +my @parts = $entity->parts(); +my $count = 0; + +foreach my $part (@parts) { + if ($part->head->mime_type eq 'text/calendar') { + my $body = $part->bodyhandle; + my $cmd = $CONVERT.' '.$body->path.' >> '.$REMINDERS; + print STDERR `$cmd`; + last if ($? != 0); + $count++; + } +} + +$parser->filer->purge; +if ($count == 0) { + print STDERR "No calendar entries found."; + exit(1); +} + +exit(0); |