blob: bdd9f235eff5b3198992ae9dd1fa032450e1c676 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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);
|