App-Greple-ical

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension App-Greple-ical

1.00 2026-07-02T22:44:15Z

    - Support recent macOS which stores calendar data in SQLite
      database instead of individual .ics files.  Events are read
      from Calendar.sqlitedb using sqlite3 command and searched in
      paragraph mode.  Requires Full Disk Access privilege for the
      terminal application.
    - Require Perl 5.24, following App::Greple requirement.

0.02 2022-10-09T09:57:39Z

    - minor misc updates

README.md  view on Meta::CPAN

greple -Mical PATTERN

greple -Mical --simple PATTERN

greple -Mical --detail PATTERN

# DESCRIPTION

This module searches Apple macOS Calendar data.

Recent versions of macOS store calendar data in a SQLite database
(`Calendar.sqlitedb` under `~/Library/Group Containers/group.com.apple.calendar`),
instead of individual `.ics` files which older versions used.  This
module reads the database with the **sqlite3** command and converts
each event to a `VEVENT`-like paragraph, which is then searched by
**greple** in paragraph mode:

     BEGIN:VEVENT
     DTSTART:20260903T163000
     DTEND:20260903T190000
     SUMMARY:映画:ローマの休日
     LOCATION:Theater X

README.md  view on Meta::CPAN

     2026/09/03 16:30-19:00 映画:ローマの休日 @[Theater X]

With **--detail** option, print summarized line with description data
if it is attached.  The result is sorted.

# REQUIREMENTS

The **sqlite3** command is required (standard on macOS).

The terminal application needs the **Full Disk Access** privilege to
read the calendar database.  If you get an "Operation not permitted"
error, add your terminal application in: System Settings ->
Privacy & Security -> Full Disk Access, and restart the terminal.

# TIPS

Use `-dfn` option to observe the command running status.

Use `-ds` option to see statistics information.

# SEE ALSO

lib/App/Greple/ical.pm  view on Meta::CPAN

greple -Mical PATTERN

greple -Mical --simple PATTERN

greple -Mical --detail PATTERN

=head1 DESCRIPTION

This module searches Apple macOS Calendar data.

Recent versions of macOS store calendar data in a SQLite database
(F<Calendar.sqlitedb> under F<~/Library/Group Containers/group.com.apple.calendar>),
instead of individual C<.ics> files which older versions used.  This
module reads the database with the B<sqlite3> command and converts
each event to a C<VEVENT>-like paragraph, which is then searched by
B<greple> in paragraph mode:

     BEGIN:VEVENT
     DTSTART:20260903T163000
     DTEND:20260903T190000
     SUMMARY:映画:ローマの休日
     LOCATION:Theater X

lib/App/Greple/ical.pm  view on Meta::CPAN

     2026/09/03 16:30-19:00 映画:ローマの休日 @[Theater X]

With B<--detail> option, print summarized line with description data
if it is attached.  The result is sorted.

=head1 REQUIREMENTS

The B<sqlite3> command is required (standard on macOS).

The terminal application needs the B<Full Disk Access> privilege to
read the calendar database.  If you get an "Operation not permitted"
error, add your terminal application in: System Settings ->
Privacy & Security -> Full Disk Access, and restart the terminal.

=head1 TIPS

Use C<-dfn> option to observe the command running status.

Use C<-ds> option to see statistics information.

=head1 SEE ALSO

lib/App/Greple/ical.pm  view on Meta::CPAN

	}
    }
    $desc;
}

1;

__DATA__

option default \
	--chdir '~/Library/Group\ Containers/group.com.apple.calendar' \
	--glob Calendar.sqlitedb \
	--if &ical_data \
	-p

option --simple \
	--print print_simple

option --detail \
	--print print_detail --pf 'sort | tr \\015 \\012'

t/01_ical.t  view on Meta::CPAN

##

chomp(my $sqlite3 = `sh -c 'command -v sqlite3' 2>/dev/null` // '');
plan skip_all => 'sqlite3 not available' unless $sqlite3;

chomp(my $greple = `sh -c 'command -v greple' 2>/dev/null` // '');
plan skip_all => 'greple not available' unless $greple;

my $home = tempdir(CLEANUP => 1);
my $dir = File::Spec->catdir($home, 'Library', 'Group Containers',
			     'group.com.apple.calendar');
make_path($dir) or die "make_path: $!";
my $db = File::Spec->catfile($dir, 'Calendar.sqlitedb');

# Core Data epoch (2001-01-01) offset from Unix epoch
use constant CD_EPOCH => 978307200;
sub cd { timegm(0, 0, $_[3] // 12, $_[2], $_[1] - 1, $_[0]) - CD_EPOCH }

my $sql = <<END;
CREATE TABLE CalendarItem (
    summary TEXT, description TEXT,



( run in 2.368 seconds using v1.01-cache-2.11-cpan-f52f0507bed )