12345678910111213141516171819202122232425262728293031323334353637383940 |
- #!/usr/bin/env perl
- use warnings;
- use strict;
- my $debug = 0;
- my $wget = "/usr/bin/wget";
- my $ical2org = "$ENV{HOME}/pipes/ical2org.pl";
- my $base_dir = "$ENV{HOME}/.calendars";
- my $org_dir = "$ENV{HOME}/Documents/org/calendars";
- my %calendars = (
- 'home' => 'https://my.owndrive.com/remote.php/caldav/calendars/PieceMaker/defaultcalendar',
- );
- chdir $base_dir;
- # acad and ooo don't work
- my @cals = qw(home);
- foreach my $cal (@cals) {
- next unless $calendars{$cal};
- my $cmd = "$wget -q -O $cal.ics.new $calendars{$cal} && mv $cal.ics.new $cal.ics";
- print STDERR "$cmd\n" if $debug;
- system $cmd;
- next unless -r "$cal.ics";
- $cmd = "$ical2org -c $cal < $base_dir/$cal.ics > $org_dir/$cal.org.new";
- print STDERR "$cmd\n" if $debug;
- system $cmd;
- if ( -s "$org_dir/$cal.org.new" ) {
- $cmd = "cp $org_dir/$cal.org.new $org_dir/$cal.org";
- print STDERR "$cmd\n" if $debug;
- system $cmd;
- }
- }
|