-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
#!/usr/bin/perl -w | ||
# | ||
# cal_futureonly.pl - | ||
# Reads iCal files and outputs events between 1 month ago and 1 year from now. | ||
# Copyright (c) 2005, 2007, 2019 Justin B. Alcorn | ||
|
||
=head1 SYNOPSIS | ||
cal_futureonly.pl --file=filname.ics > output.ics | ||
--help Usage | ||
--man Complete man page | ||
--infile (REQUIRED) name of input calendar file | ||
--file (REQUIRED) name of output calendar file | ||
Expects an ICAL stream on STDIN. Converts it to the format | ||
used by the C<remind> script and prints it to STDOUT. | ||
=head2 --infile | ||
Input file | ||
=head2 --file | ||
Output File | ||
=cut | ||
|
||
use strict; | ||
use Data::ICal; | ||
use Data::ICal::Entry; | ||
use DateTime::Span; | ||
use Data::ICal::DateTime; | ||
use DateTime; | ||
use Getopt::Long 2.24 qw':config auto_help'; | ||
use Pod::Usage; | ||
use Data::Dumper; | ||
use vars '$VERSION'; | ||
$VERSION = "0.1"; | ||
|
||
my $help; | ||
my $man; | ||
my $infile; | ||
my $file; | ||
my $debug = 0; | ||
|
||
GetOptions ( | ||
"help|?" => \$help, | ||
"man" => \$man, | ||
"debug" => \$debug, | ||
"infile=s" => \$infile, | ||
"file=s" => \$file | ||
); | ||
pod2usage(1) if $help; | ||
pod2usage(1) if (! $file); | ||
pod2usage(-verbose => 2) if $man; | ||
|
||
my $limit = DateTime->now(); | ||
$limit->subtract( months => 1); | ||
my $endlimit = DateTime->now()->add(years =>1); | ||
print STDERR "including events from: ",$limit->ymd," to: ".$endlimit->ymd,"\n" if $debug; | ||
my $span = DateTime::Span->from_datetimes( start => $limit, end => $endlimit ); | ||
print STDERR "Parsing $infile\n" if $debug; | ||
my $cal = Data::ICal->new(filename => $infile); | ||
if (! $cal) { | ||
die "Died Trying to read $infile :".$cal->error_message; | ||
} | ||
#my $archive = Data::ICal->new(filename => 'archive.ics'); | ||
print "Output = $file\n" if $debug; | ||
my $new = Data::ICal->new(); | ||
if (! $new) { | ||
die $new->error_message; | ||
} | ||
|
||
my @events = $cal->events($span); | ||
$new->add_entries(@events); | ||
|
||
open(NEW, ">$file"); | ||
print NEW $new->as_string; | ||
close NEW; | ||
exit 0; | ||
#:vim set ft=perl ts=4 sts=4 expandtab : |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/bash | ||
|
||
r=`basename $0` | ||
|
||
if [ $r == 'weeklyreminders.sh' ]; | ||
then | ||
t=14; | ||
w=Weekly; | ||
elif [ $r == 'dailyreminders.sh' ]; | ||
then | ||
t=3; | ||
w=Daily; | ||
else | ||
t=5 | ||
w=Test; | ||
fi | ||
|
||
cd .rem | ||
for d in * ; | ||
do | ||
if [ "$( ls -A $d/$w 2>/dev/null )" ]; | ||
then | ||
echo "Sending a $w reminder to $d" | ||
ft=/tmp/$d-t-$$.txt | ||
f=/tmp/$d-$$.txt | ||
echo "Reminders for next $t days:" >> $f | ||
cat /dev/null > $d/ical2rem | ||
for c in $d/*.ics | ||
do | ||
calname=`basename $c .ics | tr a-z A-Z` | ||
cat $c 2>/dev/null | sed -e "s/^SUMMARY:/SUMMARY: {${calname}} /" \ | ||
| sed -e 's/DT\([A-Z]*\);TZID=UTC:\([0-9T]*\)/DT\1:\2Z/' >> $ft | ||
done | ||
cat $ft | ~/bin/ical2rem.pl --label "Online Calendar" --heading "PRIORITY 9999" --lead-time $t >> $d/ical2rem | ||
if [ -e $d/reminders ];then r="${d}/reminders"; else r="${d}/ical2rem";fi | ||
/usr/bin/remind -q -iplain=1 $r >> $f | ||
echo " | ||
All calendars can be accessed by logging into https://calendar.google.com/ as $d@jalcorn.net | ||
" >> $f | ||
cat $f | mail -s "$w Reminders for $d" $d@jalcorn.net; | ||
cat $f | ||
rm $f | ||
rm $ft | ||
fi; | ||
done |